Skip to content

Commit 67f8d0b

Browse files
Add missing scope definitions
1 parent ff116ed commit 67f8d0b

4 files changed

Lines changed: 80 additions & 50 deletions

File tree

data/fixtures/recorded/languages/cpp/clearSubject2.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ initialState:
2828
finalState:
2929
documentContents: |
3030
int main() {
31-
switch (int i = rand() % 100; ) {
31+
switch () {
3232
default:
3333
break;
3434
}
3535
}
3636
selections:
37-
- anchor: {line: 1, character: 32}
38-
active: {line: 1, character: 32}
37+
- anchor: {line: 1, character: 10}
38+
active: {line: 1, character: 10}

packages/common/src/scopeSupportFacets/c.ts

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,47 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
55

66
export const cCoreScopeSupport: LanguageScopeSupportFacetMap = {
77
list: supported,
8+
disqualifyDelimiter: supported,
9+
switchStatementSubject: supported,
10+
functionCall: supported,
11+
functionCallee: supported,
12+
813
ifStatement: supported,
914
statement: supported,
1015
"statement.class": supported,
16+
"statement.iteration.document": supported,
17+
"statement.iteration.block": supported,
18+
1119
class: supported,
20+
"class.iteration.document": supported,
1221
className: supported,
13-
namedFunction: supported,
22+
"className.iteration.document": supported,
1423

24+
namedFunction: supported,
1525
functionName: supported,
16-
functionCall: supported,
17-
functionCallee: supported,
26+
"functionName.iteration.document": supported,
27+
"namedFunction.iteration.document": supported,
28+
1829
"argument.actual": supported,
1930
"argument.actual.iteration": supported,
2031
"argument.actual.method": supported,
2132
"argument.actual.method.iteration": supported,
2233
"argument.formal": supported,
2334
"argument.formal.iteration": supported,
2435

36+
"argumentList.actual.empty": supported,
37+
"argumentList.actual.singleLine": supported,
38+
"argumentList.actual.multiLine": supported,
39+
"argumentList.formal.empty": supported,
40+
"argumentList.formal.singleLine": supported,
41+
"argumentList.formal.multiLine": supported,
42+
2543
"comment.line": supported,
2644
"comment.block": supported,
2745
"string.singleLine": supported,
2846
"textFragment.comment.line": supported,
2947
"textFragment.comment.block": supported,
3048
"textFragment.string.singleLine": supported,
31-
disqualifyDelimiter: supported,
3249

3350
"name.assignment": supported,
3451
"name.variable": supported,
@@ -37,6 +54,7 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = {
3754
"name.field": supported,
3855
"name.argument.formal": supported,
3956
"name.argument.formal.iteration": supported,
57+
4058
"value.assignment": supported,
4159
"value.variable": supported,
4260

@@ -50,25 +68,6 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = {
5068

5169
// Unsupported
5270

53-
switchStatementSubject: unsupported,
54-
fieldAccess: unsupported,
55-
56-
"argumentList.actual.empty": unsupported,
57-
"argumentList.actual.singleLine": unsupported,
58-
"argumentList.actual.multiLine": unsupported,
59-
"argumentList.formal.empty": unsupported,
60-
"argumentList.formal.singleLine": unsupported,
61-
"argumentList.formal.multiLine": unsupported,
62-
63-
"statement.iteration.document": unsupported,
64-
"statement.iteration.block": unsupported,
65-
66-
"class.iteration.document": unsupported,
67-
"className.iteration.document": unsupported,
68-
69-
"functionName.iteration.document": unsupported,
70-
"namedFunction.iteration.document": unsupported,
71-
7271
"interior.class": unsupported,
7372
"interior.function": unsupported,
7473
"interior.if": unsupported,
@@ -77,6 +76,8 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = {
7776
"interior.ternary": unsupported,
7877
"interior.loop": unsupported,
7978

79+
fieldAccess: unsupported,
80+
8081
"branch.if": unsupported,
8182
"branch.if.iteration": unsupported,
8283
"branch.try": unsupported,

queries/c.scm

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
(type_definition)
1616
(break_statement)
1717
(case_statement)
18-
(compound_statement)
1918
(continue_statement)
2019
(do_statement)
2120
(expression_statement)
@@ -26,10 +25,28 @@
2625
(return_statement)
2726
(switch_statement)
2827
(while_statement)
28+
;; Disabled on purpose. This is commonly the entire body of a function.
29+
;; (compound_statement)
2930
] @statement
3031

3132
(if_statement) @ifStatement
3233

34+
(
35+
(translation_unit) @statement.iteration @class.iteration @className.iteration
36+
(#document-range! @statement.iteration @class.iteration @className.iteration)
37+
)
38+
(
39+
(translation_unit) @namedFunction.iteration @functionName.iteration
40+
(#document-range! @namedFunction.iteration @functionName.iteration)
41+
)
42+
43+
(_
44+
body: (_
45+
"{" @statement.iteration.start.endOf
46+
"}" @statement.iteration.end.startOf
47+
)
48+
)
49+
3350
(
3451
(string_literal) @string @textFragment
3552
(#child-range! @textFragment 0 -1 true true)
@@ -162,7 +179,8 @@
162179

163180
(switch_statement
164181
condition: (_
165-
value: (_) @private.switchStatementSubject
182+
"(" @private.switchStatementSubject.start.endOf
183+
")" @private.switchStatementSubject.end.startOf
166184
)
167185
) @_.domain
168186

@@ -206,14 +224,14 @@
206224
")" @type.removal.end
207225
) @_.domain
208226

209-
;;!! void foo(int value) {}
210-
;;! ^^^^^
227+
;;!! void foo(int aaa) {}
228+
;;! ^^^
211229
(parameter_declaration
212230
declarator: (_) @name
213231
) @_.domain
214232

215-
;;!! void foo(int value) {}
216-
;;! ^^^^^^^^^
233+
;;!! void foo(int aaa, int bbb) {}
234+
;;! ^^^^^^^ ^^^^^^^
217235
(
218236
(parameter_list
219237
(_)? @_.leading.endOf
@@ -226,8 +244,8 @@
226244
(#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n")
227245
)
228246

229-
;;!! foo(5 + 6)
230-
;;! ^^^^^
247+
;;!! foo(aaa, bbb);
248+
;;! ^^^ ^^^
231249
(
232250
(argument_list
233251
(_)? @_.leading.endOf
@@ -240,21 +258,32 @@
240258
(#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n")
241259
)
242260

261+
;;!! void foo(int aaa, int bbb) {}
262+
;;! ^^^^^^^^^^^^^^^^
243263
(_
244264
(function_declarator
245265
(parameter_list
246-
"(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf
247-
")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf
248-
)
266+
"(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf
267+
")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf
268+
) @_dummy
249269
)
250-
) @argumentOrParameter.iteration.domain
270+
(#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n")
271+
) @argumentList.domain @argumentOrParameter.iteration.domain
251272

273+
(parameter_list
274+
"(" @type.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf
275+
")" @type.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf
276+
)
277+
278+
;;!! foo(aaa, bbb);
279+
;;! ^^^^^^^^
252280
(_
253281
(argument_list
254-
"(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf
255-
")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf
256-
)
257-
) @argumentOrParameter.iteration.domain
282+
"(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf
283+
")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf
284+
) @_dummy
285+
(#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n")
286+
) @argumentList.domain @argumentOrParameter.iteration.domain
258287

259288
operator: [
260289
"->"

queries/java.scm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@
489489
">" @type.iteration.end.startOf
490490
)
491491

492-
;;!! foo(name: string) {}
493-
;;! ^^^^^^^^^^^^
492+
;;!! void foo(int aaa, int bbb) {}
493+
;;! ^^^^^^^ ^^^^^^^
494494
(_
495495
parameters: (_
496496
(_)? @_.leading.endOf
@@ -503,8 +503,8 @@
503503
(#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n")
504504
)
505505

506-
;;!! foo("bar")
507-
;;! ^^^^^
506+
;;!! foo(aaa, bbb);
507+
;;! ^^^ ^^^
508508
(
509509
(argument_list
510510
(_)? @_.leading.endOf
@@ -517,8 +517,8 @@
517517
(#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n")
518518
)
519519

520-
;;!! foo(int a) {};
521-
;;! ^^^^^
520+
;;!! void foo(int aaa, int bbb) {}
521+
;;! ^^^^^^^^^^^^^^^^
522522
(_
523523
parameters: (_
524524
"(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf
@@ -527,8 +527,8 @@
527527
(#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n")
528528
) @argumentList.domain @argumentOrParameter.iteration.domain
529529

530-
;;!! foo(1);
531-
;;! ^
530+
;;!! foo(aaa, bbb);
531+
;;! ^^^^^^^^
532532
(_
533533
(argument_list
534534
"(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf

0 commit comments

Comments
 (0)