From 8a4c83c272832cce04a2e4a9a4cea14b2d62643e Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Fri, 17 Feb 2017 16:07:44 -0500 Subject: [PATCH] Stop traversal upon finding the node --- src/NodeVisitor/NodeAtPositionFinder.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/NodeVisitor/NodeAtPositionFinder.php b/src/NodeVisitor/NodeAtPositionFinder.php index 14c4267..463c55e 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}; /** @@ -38,6 +38,7 @@ class NodeAtPositionFinder extends NodeVisitorAbstract $range = Range::fromNode($node); if ($range->includes($this->position)) { $this->node = $node; + return NodeTraverser::STOP_TRAVERSAL } } }