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 3
3
4
4
namespace LanguageServer \NodeVisitor ;
5
5
6
- use PhpParser \{NodeVisitorAbstract , Node };
6
+ use PhpParser \{NodeVisitorAbstract , Node , NodeTraverser };
7
7
use LanguageServer \Protocol \{Position , Range };
8
8
9
9
/**
@@ -15,7 +15,7 @@ class NodeAtPositionFinder extends NodeVisitorAbstract
15
15
/**
16
16
* The node at the position, if found
17
17
*
18
- * @var Node
18
+ * @var Node|null
19
19
*/
20
20
public $ node ;
21
21
@@ -34,9 +34,12 @@ public function __construct(Position $position)
34
34
35
35
public function leaveNode (Node $ node )
36
36
{
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
+ }
40
43
}
41
44
}
42
45
}
You can’t perform that action at this time.
0 commit comments