Skip to content

Commit 8a9bb11

Browse files
Statement iteration
1 parent e51c0c7 commit 8a9bb11

File tree

5 files changed

+106
-21
lines changed

5 files changed

+106
-21
lines changed

data/fixtures/scopes/java/name.iteration.block.scope

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ public class MyClass {
4343
2| if (true) { }
4444
3| }
4545
---<
46+
47+
48+
[#5 Range] =
49+
[#5 Domain] = 2:15-2:16
50+
>-<
51+
2| if (true) { }
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
public class MyClass {
2+
public void myFunk() {
3+
if (true) { }
4+
while (true) { }
5+
}
6+
}
7+
---
8+
9+
[#1 Range] =
10+
[#1 Domain] = 0:0-5:1
11+
>----------------------
12+
0| public class MyClass {
13+
1| public void myFunk() {
14+
2| if (true) { }
15+
3| while (true) { }
16+
4| }
17+
5| }
18+
-<
19+
20+
21+
[#2 Range] =
22+
[#2 Domain] = 0:22-5:0
23+
>
24+
0| public class MyClass {
25+
1| public void myFunk() {
26+
2| if (true) { }
27+
3| while (true) { }
28+
4| }
29+
5| }
30+
<
31+
32+
33+
[#3 Range] =
34+
[#3 Domain] = 1:25-4:3
35+
>
36+
1| public void myFunk() {
37+
2| if (true) { }
38+
3| while (true) { }
39+
4| }
40+
---<
41+
42+
43+
[#4 Range] =
44+
[#4 Domain] = 2:15-2:16
45+
>-<
46+
2| if (true) { }
47+
48+
49+
[#5 Range] =
50+
[#5 Domain] = 3:18-3:19
51+
>-<
52+
3| while (true) { }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
public class MyClass { }
3+
---
4+
5+
[#1 Range] =
6+
[#1 Domain] = 1:0-1:24
7+
>------------------------<
8+
1| public class MyClass { }
9+
10+
11+
[#2 Range] =
12+
[#2 Domain] = 1:22-1:23
13+
>-<
14+
1| public class MyClass { }

packages/common/src/scopeSupportFacets/java.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
8585
ifStatement: supported,
8686
statement: supported,
8787
"statement.class": supported,
88+
"statement.iteration.block": supported,
89+
"statement.iteration.document": supported,
8890

8991
"string.singleLine": supported,
9092
"string.multiLine": supported,
@@ -133,9 +135,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
133135
"interior.ternary": unsupported,
134136
"interior.try": unsupported,
135137

136-
"statement.iteration.block": unsupported,
137-
"statement.iteration.document": unsupported,
138-
139138
fieldAccess: unsupported,
140139

141140
// Not Applicable

queries/java.scm

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,46 @@
4343
) @class @_.domain
4444

4545
(program) @class.iteration @className.iteration @name.iteration
46+
(program) @statement.iteration
4647

48+
;;!! class MyClass { }
49+
;;! ^
4750
(class_body
4851
.
4952
"{" @class.iteration.start.endOf @className.iteration.start.endOf
5053
"}" @class.iteration.end.startOf @className.iteration.end.startOf
5154
.
5255
) @class.iteration.domain @className.iteration.domain
5356

57+
(class_body
58+
.
59+
"{" @type.iteration.start.endOf @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf
60+
"}" @type.iteration.end.startOf @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf
61+
.
62+
)
63+
64+
;;!! for (...) { }
65+
;;! ^
66+
(_
67+
body: (_
68+
.
69+
"{" @name.iteration.start.endOf @statement.iteration.start.endOf
70+
"}" @name.iteration.end.startOf @statement.iteration.end.startOf
71+
.
72+
)
73+
)
74+
75+
;;!! if (true) { }
76+
;;! ^
77+
(if_statement
78+
(block
79+
.
80+
"{" @name.iteration.start.endOf @statement.iteration.start.endOf
81+
"}" @name.iteration.end.startOf @statement.iteration.end.startOf
82+
.
83+
)
84+
)
85+
5486
;;!! void myFunk() {}
5587
;;! ^^^^^^^^^^^^^^^^
5688
(method_declaration
@@ -435,24 +467,6 @@
435467
type: (_) @type
436468
) @_.domain
437469

438-
;;!! class MyClass { }
439-
;;! ^
440-
(class_body
441-
.
442-
"{" @type.iteration.start.endOf @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf
443-
"}" @type.iteration.end.startOf @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf
444-
.
445-
)
446-
447-
(_
448-
body: (_
449-
.
450-
"{" @name.iteration.start.endOf
451-
"}" @name.iteration.end.startOf
452-
.
453-
)
454-
)
455-
456470
;;!! public Map<int, int> foo;
457471
;;! ^^^ ^^^
458472
(type_arguments

0 commit comments

Comments
 (0)