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

Commit 8c27a79

Browse files
committed
Merge branch 'java-finch' of github.com:github/stack-graphs into java-finch
2 parents bc779d0 + 76edb61 commit 8c27a79

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n
191191

192192
[
193193
(class_declaration)
194+
(enum_declaration)
194195
(field_declaration)
195196
(interface_declaration)
196197
(method_declaration)
@@ -227,6 +228,22 @@ attribute node_symbol = node => symbol = (source-text node), source_n
227228
edge @b.before_scope -> @a.after_scope
228229
}
229230

231+
(enum_declaration name: (_) @name) @this {
232+
node def
233+
attr (def) node_definition = @name
234+
edge @this.defs -> def
235+
236+
node @this.constants
237+
attr (@this.constants) pop_symbol = "."
238+
edge def -> @this.constants
239+
}
240+
241+
(enum_declaration (enum_body (enum_constant name: (_) @name))) @this {
242+
node def
243+
attr (def) node_definition = @name
244+
edge @this.constants -> def
245+
}
246+
230247
(field_declaration
231248
type: (_) @type
232249
declarator: (variable_declarator
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
enum A {
2+
X, Y, Z
3+
}
4+
5+
class B {
6+
void f() {
7+
f(A.X);
8+
//^ defined: 1
9+
// ^ defined: 2
10+
}
11+
}

0 commit comments

Comments
 (0)