From 7294181feb4dc8fe09c0a80d634931a7e31c73ba Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Mon, 30 Jan 2017 13:41:01 +0100 Subject: [PATCH] Use NodeTraverser::ABORT_TRAVERSAL --- src/NodeVisitor/NodeAtPositionFinder.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NodeVisitor/NodeAtPositionFinder.php b/src/NodeVisitor/NodeAtPositionFinder.php index 521d940..7c31ec6 100644 --- a/src/NodeVisitor/NodeAtPositionFinder.php +++ b/src/NodeVisitor/NodeAtPositionFinder.php @@ -3,7 +3,7 @@ declare(strict_types = 1); namespace LanguageServer\NodeVisitor; -use PhpParser\{NodeVisitorAbstract, Node}; +use PhpParser\{NodeVisitorAbstract, Node, NodeTraverser}; use LanguageServer\Protocol\{Position, Range}; /** @@ -35,8 +35,9 @@ class NodeAtPositionFinder extends NodeVisitorAbstract public function leaveNode(Node $node) { $range = Range::fromNode($node); - if (!isset($this->node) && $range->includes($this->position)) { + if ($range->includes($this->position)) { $this->node = $node; + return NodeTraverser::STOP_TRAVERSAL; } } }