File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 33
44namespace LanguageServer \NodeVisitor ;
55
6- use PhpParser \{NodeVisitorAbstract , Node };
6+ use PhpParser \{NodeVisitorAbstract , Node , NodeTraverser };
77use LanguageServer \Protocol \{Position , Range };
88
99/**
@@ -15,7 +15,7 @@ class NodeAtPositionFinder extends NodeVisitorAbstract
1515 /**
1616 * The node at the position, if found
1717 *
18- * @var Node
18+ * @var Node|null
1919 */
2020 public $ node ;
2121
@@ -34,9 +34,12 @@ public function __construct(Position $position)
3434
3535 public function leaveNode (Node $ node )
3636 {
37- $ range = Range::fromNode ($ node );
38- if (!isset ($ this ->node ) && $ range ->includes ($ this ->position )) {
39- $ this ->node = $ node ;
37+ if ($ this ->node === null ) {
38+ $ range = Range::fromNode ($ node );
39+ if ($ range ->includes ($ this ->position )) {
40+ $ this ->node = $ node ;
41+ return NodeTraverser::STOP_TRAVERSAL ;
42+ }
4043 }
4144 }
4245}
You can’t perform that action at this time.
0 commit comments