Skip to content

Commit a7afe9f

Browse files
Add resources
1 parent 7b934f6 commit a7afe9f

File tree

7 files changed

+96
-9
lines changed

7 files changed

+96
-9
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
try (PrintWriter writer = create()) { }
2+
---
3+
4+
[Content] = 0:17-0:23
5+
>------<
6+
0| try (PrintWriter writer = create()) { }
7+
8+
[Removal] = 0:17-0:24
9+
>-------<
10+
0| try (PrintWriter writer = create()) { }
11+
12+
[Leading delimiter] = 0:16-0:17
13+
>-<
14+
0| try (PrintWriter writer = create()) { }
15+
16+
[Trailing delimiter] = 0:23-0:24
17+
>-<
18+
0| try (PrintWriter writer = create()) { }
19+
20+
[Domain] = 0:0-0:39
21+
>---------------------------------------<
22+
0| try (PrintWriter writer = create()) { }
23+
24+
[Insertion delimiter] = " "
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
try (PrintWriter writer = create()) { }
2+
---
3+
4+
[Content] = 0:5-0:16
5+
>-----------<
6+
0| try (PrintWriter writer = create()) { }
7+
8+
[Removal] = 0:5-0:17
9+
>------------<
10+
0| try (PrintWriter writer = create()) { }
11+
12+
[Trailing delimiter] = 0:16-0:17
13+
>-<
14+
0| try (PrintWriter writer = create()) { }
15+
16+
[Domain] = 0:0-0:39
17+
>---------------------------------------<
18+
0| try (PrintWriter writer = create()) { }
19+
20+
[Insertion delimiter] = " "
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
try (PrintWriter writer = create()) { }
2+
---
3+
4+
[Content] = 0:26-0:34
5+
>--------<
6+
0| try (PrintWriter writer = create()) { }
7+
8+
[Removal] = 0:25-0:34
9+
>---------<
10+
0| try (PrintWriter writer = create()) { }
11+
12+
[Leading delimiter] = 0:25-0:26
13+
>-<
14+
0| try (PrintWriter writer = create()) { }
15+
16+
[Domain] = 0:0-0:39
17+
>---------------------------------------<
18+
0| try (PrintWriter writer = create()) { }
19+
20+
[Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/java.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
8080
"name.variable": supported,
8181
"name.iteration.document": supported,
8282
"name.iteration.block": supported,
83+
"name.resource": supported,
8384

8485
ifStatement: supported,
8586
statement: supported,
@@ -91,39 +92,34 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
9192
"textFragment.comment.line": supported,
9293
"textFragment.string.singleLine": supported,
9394

94-
"type.typeArgument": supported,
95-
"type.typeArgument.iteration": supported,
96-
9795
"type.argument.formal.constructor": supported,
9896
"type.argument.formal.method": supported,
9997
"type.foreach": supported,
10098
"type.field": supported,
10199
"type.field.iteration": supported,
102100
"type.return": supported,
103101
"type.variable": supported,
102+
"type.typeArgument": supported,
103+
"type.typeArgument.iteration": supported,
104+
"type.resource": supported,
104105

105106
"value.assignment": supported,
106107
"value.foreach": supported,
107108
"value.field": supported,
108109
"value.return": supported,
109110
"value.return.lambda": supported,
110111
"value.variable": supported,
112+
"value.resource": supported,
111113

112114
// Unsupported
113115

114-
"name.resource": unsupported,
115-
"name.resource.iteration": unsupported,
116-
117116
"type.argument.formal.constructor.iteration": unsupported,
118117
"type.argument.formal.method.iteration": unsupported,
119118
"type.cast": unsupported,
120119
"type.class": unsupported,
121120
"type.enum": unsupported,
122121
"type.interface": unsupported,
123122

124-
"value.resource": unsupported,
125-
"value.resource.iteration": unsupported,
126-
127123
"interior.class": unsupported,
128124
"interior.element": unsupported,
129125
"interior.function": unsupported,
@@ -151,6 +147,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
151147
"name.argument.formal.iteration": notApplicable,
152148
"name.function": notApplicable,
153149
"name.variable.pattern": notApplicable,
150+
"name.resource.iteration": notApplicable,
154151

155152
"key.mapPair": notApplicable,
156153
"key.mapPair.iteration": notApplicable,
@@ -169,10 +166,12 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
169166
"value.variable.pattern": notApplicable,
170167
"value.typeAlias": notApplicable,
171168
"value.yield": notApplicable,
169+
"value.resource.iteration": notApplicable,
172170

173171
"type.argument.formal": notApplicable,
174172
"type.argument.formal.iteration": notApplicable,
175173
"type.alias": notApplicable,
174+
"type.resource.iteration": notApplicable,
176175

177176
section: notApplicable,
178177
"section.iteration.document": notApplicable,

packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,16 @@ export const scopeSupportFacetInfos: Record<
706706
scopeType: "type",
707707
isIteration: true,
708708
},
709+
"type.resource": {
710+
description: "Type in a 'with' / 'use' / 'using' statement",
711+
scopeType: "type",
712+
},
713+
"type.resource.iteration": {
714+
description:
715+
"Iteration scope for types in a 'with' / 'use' / 'using' statement",
716+
scopeType: "type",
717+
isIteration: true,
718+
},
709719

710720
"interior.element": {
711721
description: "The interior/children of an XML element",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ export const scopeSupportFacets = [
173173
"type.class",
174174
"type.typeArgument",
175175
"type.typeArgument.iteration",
176+
"type.resource",
177+
"type.resource.iteration",
176178

177179
"interior.class",
178180
"interior.function",

queries/java.scm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,18 @@
500500
")" @argumentOrParameter.iteration.end.startOf
501501
) @argumentOrParameter.iteration.domain
502502

503+
;;!! try (PrintWriter writer = create()) { }
504+
;;! ^^^^^^^^^^^ ^^^^^ ^^^^^^^^
505+
(try_with_resources_statement
506+
(resource_specification
507+
(resource
508+
type: (_) @type
509+
name: (_) @name
510+
value: (_) @value
511+
)
512+
)
513+
) @_.domain
514+
503515
operator: [
504516
"<"
505517
"<<"

0 commit comments

Comments
 (0)