Skip to content

Commit 8ae3b75

Browse files
Added item scope to java
1 parent 4362f67 commit 8ae3b75

File tree

6 files changed

+150
-5
lines changed

6 files changed

+150
-5
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class MyClass {
2+
String foo, bar;
3+
}
4+
---
5+
6+
[Range] = 1:11-1:19
7+
>--------<
8+
1| String foo, bar;
9+
10+
[Domain] = 1:4-1:20
11+
>----------------<
12+
1| String foo, bar;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class MyClass {
2+
public void myFunk() {
3+
String foo, bar;
4+
}
5+
}
6+
---
7+
8+
[Range] = 2:15-2:23
9+
>--------<
10+
2| String foo, bar;
11+
12+
[Domain] = 2:8-2:24
13+
>----------------<
14+
2| String foo, bar;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
public class MyClass {
2+
String foo, bar;
3+
}
4+
---
5+
6+
[#1 Content] =
7+
[#1 Domain] = 1:11-1:14
8+
>---<
9+
1| String foo, bar;
10+
11+
[#1 Removal] = 1:11-1:16
12+
>-----<
13+
1| String foo, bar;
14+
15+
[#1 Trailing delimiter] = 1:14-1:16
16+
>--<
17+
1| String foo, bar;
18+
19+
[#1 Insertion delimiter] = ", "
20+
21+
22+
[#2 Content] =
23+
[#2 Domain] = 1:16-1:19
24+
>---<
25+
1| String foo, bar;
26+
27+
[#2 Removal] = 1:14-1:19
28+
>-----<
29+
1| String foo, bar;
30+
31+
[#2 Leading delimiter] = 1:14-1:16
32+
>--<
33+
1| String foo, bar;
34+
35+
[#2 Insertion delimiter] = ", "
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
public class MyClass {
2+
public void myFunk() {
3+
String foo, bar;
4+
}
5+
}
6+
---
7+
8+
[#1 Content] =
9+
[#1 Domain] = 2:15-2:18
10+
>---<
11+
2| String foo, bar;
12+
13+
[#1 Removal] = 2:15-2:20
14+
>-----<
15+
2| String foo, bar;
16+
17+
[#1 Trailing delimiter] = 2:18-2:20
18+
>--<
19+
2| String foo, bar;
20+
21+
[#1 Insertion delimiter] = ", "
22+
23+
24+
[#2 Content] =
25+
[#2 Domain] = 2:20-2:23
26+
>---<
27+
2| String foo, bar;
28+
29+
[#2 Removal] = 2:18-2:23
30+
>-----<
31+
2| String foo, bar;
32+
33+
[#2 Leading delimiter] = 2:18-2:20
34+
>--<
35+
2| String foo, bar;
36+
37+
[#2 Insertion delimiter] = ", "

packages/common/src/scopeSupportFacets/java.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,17 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
2121
"argument.actual": supported,
2222
"argument.actual.iteration": supported,
2323

24-
element: notApplicable,
25-
tags: notApplicable,
26-
attribute: notApplicable,
27-
"key.attribute": notApplicable,
28-
"value.attribute": notApplicable,
24+
"collectionItem.unenclosed": supported,
25+
"collectionItem.unenclosed.iteration": supported,
2926

3027
"branch.if": supported,
3128
"branch.if.iteration": supported,
3229
"branch.try": supported,
3330
"branch.try.iteration": supported,
31+
32+
element: notApplicable,
33+
tags: notApplicable,
34+
attribute: notApplicable,
35+
"key.attribute": notApplicable,
36+
"value.attribute": notApplicable,
3437
};

queries/java.scm

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,57 @@
316316
value: (_)? @value @name.trailing.startOf
317317
)
318318
) @_.domain
319+
319320
(field_declaration
320321
(variable_declarator
321322
name: (_) @name @value.leading.endOf
322323
value: (_)? @value @name.trailing.startOf
323324
)
324325
) @_.domain
325326

327+
;;!! int foo, bar;
328+
;;! ^^^ ^^^
329+
(
330+
(local_variable_declaration
331+
type: (_)
332+
(variable_declarator)? @_.leading.endOf
333+
.
334+
(variable_declarator) @collectionItem
335+
.
336+
(variable_declarator)? @_.trailing.startOf
337+
)
338+
(#insertion-delimiter! @collectionItem ", ")
339+
)
340+
341+
(
342+
(field_declaration
343+
type: (_)
344+
(variable_declarator)? @_.leading.endOf
345+
.
346+
(variable_declarator) @collectionItem
347+
.
348+
(variable_declarator)? @_.trailing.startOf
349+
)
350+
(#insertion-delimiter! @collectionItem ", ")
351+
)
352+
353+
;;!! int foo, bar;
354+
;;! ^^^^ ^^^^
355+
;;! -------------
356+
(local_variable_declaration
357+
type: (_)
358+
.
359+
(_) @collectionItem.iteration.start.startOf
360+
";"? @collectionItem.iteration.end.startOf
361+
) @collectionItem.iteration.domain
362+
363+
(field_declaration
364+
type: (_)
365+
.
366+
(_) @collectionItem.iteration.start.startOf
367+
";"? @collectionItem.iteration.end.startOf
368+
) @collectionItem.iteration.domain
369+
326370
;;!! value = 1;
327371
;;! ^
328372
;;! xxxx

0 commit comments

Comments
 (0)