Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 0b31c4c

Browse files
committed
Create nodes for implicit references to this.
1 parent fc198fc commit 0b31c4c

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

languages/tree-sitter-stack-graphs-java/src/stack-graphs.tsg

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,34 @@ attribute node_symbol = node => symbol = (source-text node), source_n
323323
node @method_invocation.lexical_scope
324324
}
325325

326+
; method calls with implicit receiver
326327
(method_invocation
327328
name: (identifier) @method_name) @method_invocation {
328-
node @method_name.value
329-
attr (@method_name.value) node_reference = @method_name
330-
; TODO: remove this if not needed for super
331-
edge @method_name.value -> @method_invocation.before_scope
332-
node @method_invocation.defs
333-
edge @method_name.value -> @method_invocation.lexical_scope
329+
node member
330+
node implicit_this
331+
node implicit_this__typeof
332+
333+
; attr (implicit_this) node_reference = @method_invocation
334+
attr (implicit_this) push_symbol = "this", empty_source_span
335+
336+
; receiver is implicitly "this"
337+
edge implicit_this__typeof -> implicit_this
338+
attr (implicit_this__typeof) push_symbol = ":"
339+
edge implicit_this -> @method_invocation.lexical_scope
340+
341+
node expr_ref
342+
attr (expr_ref) node_reference = @method_name
343+
edge expr_ref -> member
344+
345+
attr (member) push_symbol = "."
346+
347+
edge member -> implicit_this__typeof
348+
349+
node expr_ref__typeof
350+
edge @method_invocation.type -> expr_ref__typeof
351+
352+
attr (expr_ref__typeof) push_symbol = ":"
353+
edge expr_ref__typeof -> expr_ref
334354
}
335355

336356
(local_variable_declaration

0 commit comments

Comments
 (0)