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

Commit 817cda2

Browse files
committed
Update class_extension example and tests
1 parent b3edb51 commit 817cda2

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ attribute node_symbol = node => symbol = (source-text node), source_n
150150
edge @class.type -> ref
151151
}
152152

153+
(class_declaration
154+
superclass: (superclass
155+
(generic_type
156+
(type_identifier)) @superclass_name)) @class {
157+
edge @superclass_name.lexical_scope -> @class.lexical_scope
158+
}
159+
153160

154161
(class_declaration (type_parameters)) @class {
155162
node @class.type_parameters
@@ -361,7 +368,7 @@ attribute node_symbol = node => symbol = (source-text node), source_n
361368
type_parameters: (type_parameters
362369
(type_parameter
363370
(type_identifier) @type_identifier))
364-
body:(_) @body) @this {
371+
body: (_) @body) @this {
365372
node type_ident
366373
attr (type_ident) node_definition = @type_identifier
367374
edge @body.lexical_scope -> type_ident
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
class TestClass extends SecondTestClass {
2-
// ^ defined: 5
1+
class String {
2+
public int length() {}
3+
};
4+
5+
class HashMap<K, V> {
6+
public Set<MapEntry<K, V>> entrySet() {}
7+
// ^ defined: 5
8+
}
9+
10+
class LRUCache<K, V>
11+
extends HashMap<K, V> {
12+
// ^ defined: 5
13+
// ^ defined: 10
14+
// ^ defined: 10
315
}
416

5-
class SecondTestClass {
17+
class MyMap extends LRUCache<String, String> {
18+
public int go() {
19+
return this.entrySet().iterator().next().getKey().length();
20+
// ^ defined: 2
21+
}
622
}

0 commit comments

Comments
 (0)