Skip to content

Commit 0336f30

Browse files
Added java field type (#2364)
## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent ba52ccd commit 0336f30

File tree

8 files changed

+194
-0
lines changed

8 files changed

+194
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class MyClass {
2+
Map<int, int> foo;
3+
}
4+
---
5+
6+
[#1 Range] =
7+
[#1 Domain] = 0:15-2:0
8+
>
9+
0| class MyClass {
10+
1| Map<int, int> foo;
11+
2| }
12+
<
13+
14+
15+
[#2 Range] =
16+
[#2 Domain] = 1:8-1:16
17+
>--------<
18+
1| Map<int, int> foo;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class MyClass {
2+
Map<int, int> foo;
3+
}
4+
---
5+
6+
[#1 Content] = 1:4-1:17
7+
>-------------<
8+
1| Map<int, int> foo;
9+
10+
[#1 Removal] = 1:4-1:18
11+
>--------------<
12+
1| Map<int, int> foo;
13+
14+
[#1 Leading delimiter] = 1:0-1:4
15+
>----<
16+
1| Map<int, int> foo;
17+
18+
[#1 Trailing delimiter] = 1:17-1:18
19+
>-<
20+
1| Map<int, int> foo;
21+
22+
[#1 Domain] = 1:4-1:22
23+
>------------------<
24+
1| Map<int, int> foo;
25+
26+
[#1 Insertion delimiter] = " "
27+
28+
29+
[#2 Content] =
30+
[#2 Removal] =
31+
[#2 Domain] = 1:8-1:11
32+
>---<
33+
1| Map<int, int> foo;
34+
35+
[#2 Insertion delimiter] = " "
36+
37+
38+
[#3 Content] =
39+
[#3 Domain] = 1:13-1:16
40+
>---<
41+
1| Map<int, int> foo;
42+
43+
[#3 Removal] = 1:12-1:16
44+
>----<
45+
1| Map<int, int> foo;
46+
47+
[#3 Leading delimiter] = 1:12-1:13
48+
>-<
49+
1| Map<int, int> foo;
50+
51+
[#3 Insertion delimiter] = " "
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class MyClass {
2+
Map<int, int> foo;
3+
}
4+
---
5+
6+
[#1 Range] =
7+
[#1 Domain] = 0:15-2:0
8+
>
9+
0| class MyClass {
10+
1| Map<int, int> foo;
11+
2| }
12+
<
13+
14+
15+
[#2 Range] =
16+
[#2 Domain] = 1:8-1:16
17+
>--------<
18+
1| Map<int, int> foo;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class MyClass {
2+
Map<int, int> foo;
3+
}
4+
---
5+
6+
[#1 Content] = 1:4-1:17
7+
>-------------<
8+
1| Map<int, int> foo;
9+
10+
[#1 Removal] = 1:4-1:18
11+
>--------------<
12+
1| Map<int, int> foo;
13+
14+
[#1 Leading delimiter] = 1:0-1:4
15+
>----<
16+
1| Map<int, int> foo;
17+
18+
[#1 Trailing delimiter] = 1:17-1:18
19+
>-<
20+
1| Map<int, int> foo;
21+
22+
[#1 Domain] = 1:4-1:22
23+
>------------------<
24+
1| Map<int, int> foo;
25+
26+
[#1 Insertion delimiter] = " "
27+
28+
29+
[#2 Content] =
30+
[#2 Removal] =
31+
[#2 Domain] = 1:8-1:11
32+
>---<
33+
1| Map<int, int> foo;
34+
35+
[#2 Insertion delimiter] = " "
36+
37+
38+
[#3 Content] =
39+
[#3 Domain] = 1:13-1:16
40+
>---<
41+
1| Map<int, int> foo;
42+
43+
[#3 Removal] = 1:12-1:16
44+
>----<
45+
1| Map<int, int> foo;
46+
47+
[#3 Leading delimiter] = 1:12-1:13
48+
>-<
49+
1| Map<int, int> foo;
50+
51+
[#3 Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/java.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,15 @@ const { supported, notApplicable } = ScopeSupportFacetLevel;
99

1010
export const javaScopeSupport: LanguageScopeSupportFacetMap = {
1111
"name.foreach": supported,
12+
1213
"value.foreach": supported,
14+
1315
"type.foreach": supported,
16+
"type.field": supported,
17+
"type.field.iteration": supported,
18+
"type.typeArgument": supported,
19+
"type.typeArgument.iteration": supported,
20+
1421
"argument.formal": supported,
1522
"argument.formal.iteration": supported,
1623
"argument.actual": supported,

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,12 @@ export const scopeSupportFacetInfos: Record<
397397
description: "Type of field in a class / interface",
398398
scopeType: "type",
399399
},
400+
"type.field.iteration": {
401+
description:
402+
"Iteration scope for type of field in a class / interface; should be entire class / interface body",
403+
scopeType: "type",
404+
isIteration: true,
405+
},
400406
"type.foreach": {
401407
description: "Type of variable in a for each loop",
402408
scopeType: "type",
@@ -417,4 +423,14 @@ export const scopeSupportFacetInfos: Record<
417423
description: "A type cast",
418424
scopeType: "type",
419425
},
426+
"type.typeArgument": {
427+
description: "Type argument to a generic / parametrized type",
428+
scopeType: "type",
429+
},
430+
"type.typeArgument.iteration": {
431+
description:
432+
"Iteration scope for type argument to a generic / parametrized type; Should be the list of type arguments",
433+
scopeType: "type",
434+
isIteration: true,
435+
},
420436
};

packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,14 @@ const scopeSupportFacets = [
101101
"type.formalParameter",
102102
"type.return",
103103
"type.field",
104+
"type.field.iteration",
104105
"type.foreach",
105106
"type.interface",
106107
"type.alias",
107108
"type.cast",
108109
"type.class",
110+
"type.typeArgument",
111+
"type.typeArgument.iteration",
109112

110113
// FIXME: Still in legacy
111114
// section

queries/java.scm

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,36 @@
327327
(#not-type? @value block)
328328
) @_.domain
329329

330+
;;!! public Map<int, int> foo;
331+
;;! ^^^^^^^^^^^^^
332+
;;! -------------------------
333+
(field_declaration
334+
type: (_) @type
335+
) @_.domain
336+
337+
;;!! class MyClass { }
338+
;;! ^
339+
(class_body
340+
.
341+
"{" @type.iteration.start.endOf
342+
"}" @type.iteration.end.startOf
343+
.
344+
)
345+
346+
;;!! public Map<int, int> foo;
347+
;;! ^^^ ^^^
348+
(type_arguments
349+
(_) @type
350+
)
351+
352+
;;!! public Map<int, int> foo;
353+
;;! ^^^^^^^^
354+
(type_arguments
355+
.
356+
"<" @type.iteration.start.endOf
357+
">" @type.iteration.end.startOf
358+
.
359+
)
330360
;;!! foo(name: string) {}
331361
;;! ^^^^^^^^^^^^
332362
(

0 commit comments

Comments
 (0)