From 136f8c617b67c9505517397fe25ff86da5024b0c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 06:45:53 +0200 Subject: [PATCH 01/10] Adding more csharp scopes --- .../argument.formal.lambda.iteration.scope | 10 ++++++ .../csharp/argument.formal.lambda.scope | 33 +++++++++++++++++++ .../scopes/csharp/comment.block.scope | 17 ++++++++++ .../fixtures/scopes/csharp/comment.line.scope | 10 ++++++ .../scopes/csharp/statement.class.scope | 10 ++++++ .../csharp/statement.iteration.block.scope | 13 ++++++++ .../csharp/statement.iteration.block2.scope | 13 ++++++++ .../csharp/statement.iteration.document.scope | 18 ++++++++++ data/fixtures/scopes/csharp/statement.scope | 10 ++++++ .../scopes/csharp/string.multiLine.scope | 13 ++++++++ .../scopes/csharp/string.singleLine.scope | 10 ++++++ .../textFragment.string.multiLine.scope | 13 ++++++++ .../textFragment.string.singleLine.scope | 10 ++++++ .../common/src/scopeSupportFacets/csharp.ts | 24 +++++++++++++- .../delimiterMaps.ts | 7 ++++ queries/csharp.scm | 17 ++++++++++ 16 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/csharp/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/csharp/argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/csharp/comment.block.scope create mode 100644 data/fixtures/scopes/csharp/comment.line.scope create mode 100644 data/fixtures/scopes/csharp/statement.class.scope create mode 100644 data/fixtures/scopes/csharp/statement.iteration.block.scope create mode 100644 data/fixtures/scopes/csharp/statement.iteration.block2.scope create mode 100644 data/fixtures/scopes/csharp/statement.iteration.document.scope create mode 100644 data/fixtures/scopes/csharp/statement.scope create mode 100644 data/fixtures/scopes/csharp/string.multiLine.scope create mode 100644 data/fixtures/scopes/csharp/string.singleLine.scope create mode 100644 data/fixtures/scopes/csharp/textFragment.string.multiLine.scope create mode 100644 data/fixtures/scopes/csharp/textFragment.string.singleLine.scope diff --git a/data/fixtures/scopes/csharp/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/csharp/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..2eedb09354 --- /dev/null +++ b/data/fixtures/scopes/csharp/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +(a, b) => {} +--- + +[Range] = 0:1-0:5 + >----< +0| (a, b) => {} + +[Domain] = 0:0-0:12 + >------------< +0| (a, b) => {} diff --git a/data/fixtures/scopes/csharp/argument.formal.lambda.scope b/data/fixtures/scopes/csharp/argument.formal.lambda.scope new file mode 100644 index 0000000000..02a715e97c --- /dev/null +++ b/data/fixtures/scopes/csharp/argument.formal.lambda.scope @@ -0,0 +1,33 @@ +(a, b) => {} +--- + +[#1 Content] = +[#1 Domain] = 0:1-0:2 + >-< +0| (a, b) => {} + +[#1 Removal] = 0:1-0:4 + >---< +0| (a, b) => {} + +[#1 Trailing delimiter] = 0:2-0:4 + >--< +0| (a, b) => {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:5 + >-< +0| (a, b) => {} + +[#2 Removal] = 0:2-0:5 + >---< +0| (a, b) => {} + +[#2 Leading delimiter] = 0:2-0:4 + >--< +0| (a, b) => {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/csharp/comment.block.scope b/data/fixtures/scopes/csharp/comment.block.scope new file mode 100644 index 0000000000..90f30164f9 --- /dev/null +++ b/data/fixtures/scopes/csharp/comment.block.scope @@ -0,0 +1,17 @@ +/* + Hello + world +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-3:2 + >--- +0| /* +1| Hello +2| world +3| */ + --< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/csharp/comment.line.scope b/data/fixtures/scopes/csharp/comment.line.scope new file mode 100644 index 0000000000..7d1477b8a1 --- /dev/null +++ b/data/fixtures/scopes/csharp/comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/csharp/statement.class.scope b/data/fixtures/scopes/csharp/statement.class.scope new file mode 100644 index 0000000000..bcfb80fe89 --- /dev/null +++ b/data/fixtures/scopes/csharp/statement.class.scope @@ -0,0 +1,10 @@ +class MyClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/csharp/statement.iteration.block.scope b/data/fixtures/scopes/csharp/statement.iteration.block.scope new file mode 100644 index 0000000000..a9bd7ec26f --- /dev/null +++ b/data/fixtures/scopes/csharp/statement.iteration.block.scope @@ -0,0 +1,13 @@ +class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/csharp/statement.iteration.block2.scope b/data/fixtures/scopes/csharp/statement.iteration.block2.scope new file mode 100644 index 0000000000..3736f6b85b --- /dev/null +++ b/data/fixtures/scopes/csharp/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +void MyFunk() { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| void MyFunk() { } + + +[#2 Range] = +[#2 Domain] = 0:15-0:16 + >-< +0| void MyFunk() { } diff --git a/data/fixtures/scopes/csharp/statement.iteration.document.scope b/data/fixtures/scopes/csharp/statement.iteration.document.scope new file mode 100644 index 0000000000..a1948c1fe5 --- /dev/null +++ b/data/fixtures/scopes/csharp/statement.iteration.document.scope @@ -0,0 +1,18 @@ + +class MyClass {} + +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:0 + > +0| +1| class MyClass {} +2| + < + + +[#2 Range] = +[#2 Domain] = 1:15-1:15 + >< +1| class MyClass {} diff --git a/data/fixtures/scopes/csharp/statement.scope b/data/fixtures/scopes/csharp/statement.scope new file mode 100644 index 0000000000..80a2e8baf9 --- /dev/null +++ b/data/fixtures/scopes/csharp/statement.scope @@ -0,0 +1,10 @@ +int value = 2; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| int value = 2; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/csharp/string.multiLine.scope b/data/fixtures/scopes/csharp/string.multiLine.scope new file mode 100644 index 0000000000..ad49870e40 --- /dev/null +++ b/data/fixtures/scopes/csharp/string.multiLine.scope @@ -0,0 +1,13 @@ +@"hello +world"; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:6 + >------- +0| @"hello +1| world"; + ------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/string.singleLine.scope b/data/fixtures/scopes/csharp/string.singleLine.scope new file mode 100644 index 0000000000..60e24228a6 --- /dev/null +++ b/data/fixtures/scopes/csharp/string.singleLine.scope @@ -0,0 +1,10 @@ +"hello world"; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "hello world"; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/textFragment.string.multiLine.scope b/data/fixtures/scopes/csharp/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..bf3f875972 --- /dev/null +++ b/data/fixtures/scopes/csharp/textFragment.string.multiLine.scope @@ -0,0 +1,13 @@ +@"hello +world"; +--- + +[Content] = +[Removal] = +[Domain] = 0:2-1:5 + >----- +0| @"hello +1| world"; + -----< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/textFragment.string.singleLine.scope b/data/fixtures/scopes/csharp/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..4ea57d25f0 --- /dev/null +++ b/data/fixtures/scopes/csharp/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"hello world"; +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "hello world"; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 29754f67fa..d31528acec 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -4,7 +4,6 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, notApplicable } = ScopeSupportFacetLevel; export const csharpScopeSupport: LanguageScopeSupportFacetMap = { - ifStatement: supported, switchStatementSubject: supported, anonymousFunction: supported, map: supported, @@ -20,6 +19,9 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "className.iteration.document": supported, "className.iteration.block": supported, + "comment.line": supported, + "comment.block": supported, + functionCall: supported, "functionCall.constructor": supported, functionCallee: supported, @@ -87,11 +89,24 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "argument.actual.method.iteration": supported, "argument.formal": supported, "argument.formal.iteration": supported, + "argument.formal.lambda": supported, + "argument.formal.lambda.iteration": supported, "argument.formal.constructor": supported, "argument.formal.constructor.iteration": supported, "argument.formal.method": supported, "argument.formal.method.iteration": supported, + ifStatement: supported, + statement: supported, + "statement.class": supported, + "statement.iteration.block": supported, + "statement.iteration.document": supported, + + "string.singleLine": supported, + "string.multiLine": supported, + "textFragment.string.singleLine": supported, + "textFragment.string.multiLine": supported, + // Not applicable "interior.element": notApplicable, @@ -108,4 +123,11 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { section: notApplicable, startTag: notApplicable, tags: notApplicable, + "collectionItem.unenclosed": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + "functionName.iteration.document": notApplicable, + "functionName.iteration.block": notApplicable, + "namedFunction.iteration.document": notApplicable, + "namedFunction.iteration.block": notApplicable, + pairDelimiter: notApplicable, }; diff --git a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts index b91b10517f..ee6017954b 100644 --- a/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts +++ b/packages/cursorless-engine/src/processTargets/modifiers/scopeHandlers/SurroundingPairScopeHandler/delimiterMaps.ts @@ -73,6 +73,13 @@ const delimiterToTextOverrides: Record> = { ruby: { tripleDoubleQuotes: ["%Q(", ")"], }, + + csharp: { + doubleQuotes: [ + ['@"', '"'], + ['"', '"'], + ], + }, }; export const leftToRightMap: Record = Object.fromEntries( diff --git a/queries/csharp.scm b/queries/csharp.scm index ceb1bf913d..854d519ff2 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -50,6 +50,18 @@ (if_statement) @ifStatement +( + (compilation_unit) @statement.iteration + (#document-range! @statement.iteration) +) + +(_ + body: (_ + "{" @statement.iteration.start.endOf + "}" @statement.iteration.end.startOf + ) +) + ;;!! if () {} ;;! ^^^^^^^^ ( @@ -147,6 +159,11 @@ (#child-range! @textFragment 0 -1 true true) ) +( + (verbatim_string_literal) @string @textFragment + (#character-range! @textFragment 2 -1) +) + (comment) @comment @textFragment (lambda_expression) @anonymousFunction From b35f1140b47021488816c9cfa7b1c7cc753ff563 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 07:12:07 +0200 Subject: [PATCH 02/10] Add name --- ...rgument.formal.constructor.iteration.scope | 33 ++++++++++ .../name.argument.formal.constructor.scope | 64 +++++++++++++++++++ .../name.argument.formal.iteration.scope | 12 +++- ...ame.argument.formal.method.iteration.scope | 33 ++++++++++ .../csharp/name.argument.formal.method.scope | 64 +++++++++++++++++++ data/fixtures/scopes/csharp/name.class.scope | 24 +++++++ .../scopes/csharp/name.constructor.scope | 45 +++++++++++++ data/fixtures/scopes/csharp/name.field.scope | 48 ++++++++++++++ .../fixtures/scopes/csharp/name.foreach.scope | 24 +++++++ .../scopes/csharp/name.function.scope | 17 +++++ .../csharp/name.iteration.document.scope | 18 ++++++ data/fixtures/scopes/csharp/name.method.scope | 45 +++++++++++++ .../common/src/scopeSupportFacets/csharp.ts | 37 ++++++++--- queries/csharp.scm | 10 ++- 14 files changed, 459 insertions(+), 15 deletions(-) create mode 100644 data/fixtures/scopes/csharp/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/csharp/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/csharp/name.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/csharp/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/csharp/name.class.scope create mode 100644 data/fixtures/scopes/csharp/name.constructor.scope create mode 100644 data/fixtures/scopes/csharp/name.field.scope create mode 100644 data/fixtures/scopes/csharp/name.foreach.scope create mode 100644 data/fixtures/scopes/csharp/name.function.scope create mode 100644 data/fixtures/scopes/csharp/name.iteration.document.scope create mode 100644 data/fixtures/scopes/csharp/name.method.scope diff --git a/data/fixtures/scopes/csharp/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/csharp/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..9c96bc5807 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.argument.formal.constructor.iteration.scope @@ -0,0 +1,33 @@ +class MyClass { + MyClass(int foo, int bar) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| MyClass(int foo, int bar) {} +2| } + -< + + +[#2 Range] = +[#2 Domain] = 0:15-2:0 + > +0| class MyClass { +1| MyClass(int foo, int bar) {} +2| } + < + + +[#3 Range] = +[#3 Domain] = 1:12-1:28 + >----------------< +1| MyClass(int foo, int bar) {} + + +[#4 Range] = +[#4 Domain] = 1:31-1:31 + >< +1| MyClass(int foo, int bar) {} diff --git a/data/fixtures/scopes/csharp/name.argument.formal.constructor.scope b/data/fixtures/scopes/csharp/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..264d3d503a --- /dev/null +++ b/data/fixtures/scopes/csharp/name.argument.formal.constructor.scope @@ -0,0 +1,64 @@ +class MyClass { + MyClass(int foo) {} +} +--- + +[#1 Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[#1 Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| MyClass(int foo) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:4-1:11 + >-------< +1| MyClass(int foo) {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| MyClass(int foo) {} + +[#2 Domain] = 1:4-1:23 + >-------------------< +1| MyClass(int foo) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:16-1:19 + >---< +1| MyClass(int foo) {} + +[#3 Removal] = 1:15-1:19 + >----< +1| MyClass(int foo) {} + +[#3 Leading delimiter] = 1:15-1:16 + >-< +1| MyClass(int foo) {} + +[#3 Domain] = 1:12-1:19 + >-------< +1| MyClass(int foo) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.argument.formal.iteration.scope b/data/fixtures/scopes/csharp/name.argument.formal.iteration.scope index 772228f4b6..cf46c08764 100644 --- a/data/fixtures/scopes/csharp/name.argument.formal.iteration.scope +++ b/data/fixtures/scopes/csharp/name.argument.formal.iteration.scope @@ -2,12 +2,18 @@ void myFunk(String name, int value) {} --- [#1 Range] = -[#1 Domain] = 0:12-0:34 - >----------------------< +[#1 Domain] = 0:0-0:38 + >--------------------------------------< 0| void myFunk(String name, int value) {} [#2 Range] = -[#2 Domain] = 0:37-0:37 +[#2 Domain] = 0:12-0:34 + >----------------------< +0| void myFunk(String name, int value) {} + + +[#3 Range] = +[#3 Domain] = 0:37-0:37 >< 0| void myFunk(String name, int value) {} diff --git a/data/fixtures/scopes/csharp/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/csharp/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..e621de9367 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.argument.formal.method.iteration.scope @@ -0,0 +1,33 @@ +class MyClass { + void funk(int foo, int bar) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| void funk(int foo, int bar) {} +2| } + -< + + +[#2 Range] = +[#2 Domain] = 0:15-2:0 + > +0| class MyClass { +1| void funk(int foo, int bar) {} +2| } + < + + +[#3 Range] = +[#3 Domain] = 1:14-1:30 + >----------------< +1| void funk(int foo, int bar) {} + + +[#4 Range] = +[#4 Domain] = 1:33-1:33 + >< +1| void funk(int foo, int bar) {} diff --git a/data/fixtures/scopes/csharp/name.argument.formal.method.scope b/data/fixtures/scopes/csharp/name.argument.formal.method.scope new file mode 100644 index 0000000000..a4e449bcc6 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.argument.formal.method.scope @@ -0,0 +1,64 @@ +class MyClass { + void funk(int foo) {} +} +--- + +[#1 Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[#1 Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| void funk(int foo) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:13 + >----< +1| void funk(int foo) {} + +[#2 Leading delimiter] = 1:8-1:9 + >-< +1| void funk(int foo) {} + +[#2 Domain] = 1:4-1:25 + >---------------------< +1| void funk(int foo) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:18-1:21 + >---< +1| void funk(int foo) {} + +[#3 Removal] = 1:17-1:21 + >----< +1| void funk(int foo) {} + +[#3 Leading delimiter] = 1:17-1:18 + >-< +1| void funk(int foo) {} + +[#3 Domain] = 1:14-1:21 + >-------< +1| void funk(int foo) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.class.scope b/data/fixtures/scopes/csharp/name.class.scope new file mode 100644 index 0000000000..004c73ac7b --- /dev/null +++ b/data/fixtures/scopes/csharp/name.class.scope @@ -0,0 +1,24 @@ +class MyClass {} +--- + +[Content] = 0:6-0:13 + >-------< +0| class MyClass {} + +[Removal] = 0:6-0:14 + >--------< +0| class MyClass {} + +[Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass {} + +[Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass {} + +[Domain] = 0:0-0:16 + >----------------< +0| class MyClass {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.constructor.scope b/data/fixtures/scopes/csharp/name.constructor.scope new file mode 100644 index 0000000000..62614526f6 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.constructor.scope @@ -0,0 +1,45 @@ +class MyClass { + MyClass() {} +} +--- + +[#1 Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[#1 Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| MyClass() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:4-1:11 + >-------< +1| MyClass() {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| MyClass() {} + +[#2 Domain] = 1:4-1:16 + >------------< +1| MyClass() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.field.scope b/data/fixtures/scopes/csharp/name.field.scope new file mode 100644 index 0000000000..1dea8fe9b3 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.field.scope @@ -0,0 +1,48 @@ +class MyClass { + int value; +} +--- + +[#1 Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[#1 Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| int value; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:13 + >-----< +1| int value; + +[#2 Removal] = 1:7-1:13 + >------< +1| int value; + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| int value; + +[#2 Domain] = 1:4-1:13 + >---------< +1| int value; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.foreach.scope b/data/fixtures/scopes/csharp/name.foreach.scope new file mode 100644 index 0000000000..e102189616 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.foreach.scope @@ -0,0 +1,24 @@ +foreach (int value in values) {} +--- + +[Content] = 0:13-0:18 + >-----< +0| foreach (int value in values) {} + +[Removal] = 0:13-0:19 + >------< +0| foreach (int value in values) {} + +[Leading delimiter] = 0:12-0:13 + >-< +0| foreach (int value in values) {} + +[Trailing delimiter] = 0:18-0:19 + >-< +0| foreach (int value in values) {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| foreach (int value in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.function.scope b/data/fixtures/scopes/csharp/name.function.scope new file mode 100644 index 0000000000..80cde86ee4 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.function.scope @@ -0,0 +1,17 @@ +void foo() {} +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void foo() {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| void foo() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/name.iteration.document.scope b/data/fixtures/scopes/csharp/name.iteration.document.scope new file mode 100644 index 0000000000..a1948c1fe5 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.iteration.document.scope @@ -0,0 +1,18 @@ + +class MyClass {} + +--- + +[#1 Range] = +[#1 Domain] = 0:0-2:0 + > +0| +1| class MyClass {} +2| + < + + +[#2 Range] = +[#2 Domain] = 1:15-1:15 + >< +1| class MyClass {} diff --git a/data/fixtures/scopes/csharp/name.method.scope b/data/fixtures/scopes/csharp/name.method.scope new file mode 100644 index 0000000000..219e506b77 --- /dev/null +++ b/data/fixtures/scopes/csharp/name.method.scope @@ -0,0 +1,45 @@ +class MyClass { + void funk() {} +} +--- + +[#1 Content] = 0:6-0:13 + >-------< +0| class MyClass { + +[#1 Removal] = 0:6-0:14 + >--------< +0| class MyClass { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class MyClass { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| class MyClass { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| void funk() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:13 + >----< +1| void funk() {} + +[#2 Leading delimiter] = 1:8-1:9 + >-< +1| void funk() {} + +[#2 Domain] = 1:4-1:18 + >--------------< +1| void funk() {} + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index d31528acec..ccfaff8a3b 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -54,10 +54,22 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "condition.ternary": supported, "condition.switchCase.iteration": supported, - "name.variable": supported, - "name.assignment": supported, - "name.argument.formal": supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, "name.argument.formal.iteration": supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal": supported, + "name.assignment": supported, + "name.class": supported, + "name.constructor": supported, + "name.field": supported, + "name.foreach": supported, + "name.function": supported, + "name.iteration.block": supported, + "name.iteration.document": supported, + "name.method": supported, + "name.variable": supported, "value.variable": supported, "value.assignment": supported, @@ -109,8 +121,19 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { // Not applicable + "collectionItem.unenclosed.iteration": notApplicable, + "collectionItem.unenclosed": notApplicable, + "functionName.iteration.block": notApplicable, + "functionName.iteration.document": notApplicable, "interior.element": notApplicable, "key.attribute": notApplicable, + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "name.variable.pattern": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "namedFunction.iteration.block": notApplicable, + "namedFunction.iteration.document": notApplicable, "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, "textFragment.element": notApplicable, @@ -119,15 +142,9 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { endTag: notApplicable, environment: notApplicable, notebookCell: notApplicable, + pairDelimiter: notApplicable, regularExpression: notApplicable, section: notApplicable, startTag: notApplicable, tags: notApplicable, - "collectionItem.unenclosed": notApplicable, - "collectionItem.unenclosed.iteration": notApplicable, - "functionName.iteration.document": notApplicable, - "functionName.iteration.block": notApplicable, - "namedFunction.iteration.document": notApplicable, - "namedFunction.iteration.block": notApplicable, - pairDelimiter: notApplicable, }; diff --git a/queries/csharp.scm b/queries/csharp.scm index 854d519ff2..37628c29b8 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -51,8 +51,8 @@ (if_statement) @ifStatement ( - (compilation_unit) @statement.iteration - (#document-range! @statement.iteration) + (compilation_unit) @statement.iteration @name.iteration + (#document-range! @statement.iteration @name.iteration) ) (_ @@ -122,6 +122,12 @@ (do_statement) ] @branch +;;!! foreach (int value in values) {} +;;! ^^^^^ +(for_each_statement + left: (_) @name +) @_.domain + ;;!! true ? 0 : 1; ;;! ^^^^ ;;! ^ ^ From 487f405015a9d74b1ffbec449505a51774550eaa Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 07:23:57 +0200 Subject: [PATCH 03/10] More scopes --- .../scopes/csharp/name.iteration.block.scope | 13 ++++++++++ .../scopes/csharp/name.iteration.block2.scope | 19 ++++++++++++++ .../csharp/textFragment.comment.block.scope | 17 ++++++++++++ .../csharp/textFragment.comment.line.scope | 10 +++++++ .../common/src/scopeSupportFacets/csharp.ts | 26 ++++++++++++++++--- 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 data/fixtures/scopes/csharp/name.iteration.block.scope create mode 100644 data/fixtures/scopes/csharp/name.iteration.block2.scope create mode 100644 data/fixtures/scopes/csharp/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/csharp/textFragment.comment.line.scope diff --git a/data/fixtures/scopes/csharp/name.iteration.block.scope b/data/fixtures/scopes/csharp/name.iteration.block.scope new file mode 100644 index 0000000000..a9bd7ec26f --- /dev/null +++ b/data/fixtures/scopes/csharp/name.iteration.block.scope @@ -0,0 +1,13 @@ +class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/csharp/name.iteration.block2.scope b/data/fixtures/scopes/csharp/name.iteration.block2.scope new file mode 100644 index 0000000000..4ae59561fa --- /dev/null +++ b/data/fixtures/scopes/csharp/name.iteration.block2.scope @@ -0,0 +1,19 @@ +void MyFunk() { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| void MyFunk() { } + + +[#2 Range] = +[#2 Domain] = 0:12-0:12 + >< +0| void MyFunk() { } + + +[#3 Range] = +[#3 Domain] = 0:15-0:16 + >-< +0| void MyFunk() { } diff --git a/data/fixtures/scopes/csharp/textFragment.comment.block.scope b/data/fixtures/scopes/csharp/textFragment.comment.block.scope new file mode 100644 index 0000000000..e84187cf56 --- /dev/null +++ b/data/fixtures/scopes/csharp/textFragment.comment.block.scope @@ -0,0 +1,17 @@ +/* + Hello + World +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-3:2 + >-- +0| /* +1| Hello +2| World +3| */ + --< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/textFragment.comment.line.scope b/data/fixtures/scopes/csharp/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/data/fixtures/scopes/csharp/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index ccfaff8a3b..7951b03562 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -1,7 +1,7 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, notApplicable } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const csharpScopeSupport: LanguageScopeSupportFacetMap = { switchStatementSubject: supported, @@ -116,8 +116,22 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "string.singleLine": supported, "string.multiLine": supported, + "textFragment.string.singleLine": supported, "textFragment.string.multiLine": supported, + "textFragment.comment.line": supported, + "textFragment.comment.block": supported, + + // Unsupported + + "interior.class": unsupported, + "interior.function": unsupported, + "interior.if": unsupported, + "interior.lambda": unsupported, + "interior.loop": unsupported, + "interior.switchCase": unsupported, + "interior.ternary": unsupported, + "interior.try": unsupported, // Not applicable @@ -125,13 +139,17 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "collectionItem.unenclosed": notApplicable, "functionName.iteration.block": notApplicable, "functionName.iteration.document": notApplicable, + "interior.cell": notApplicable, + "interior.command": notApplicable, "interior.element": notApplicable, + "interior.resource": notApplicable, "key.attribute": notApplicable, - "name.argument.actual": notApplicable, "name.argument.actual.iteration": notApplicable, - "name.variable.pattern": notApplicable, - "name.resource": notApplicable, + "name.argument.actual": notApplicable, + "name.assignment.pattern": notApplicable, "name.resource.iteration": notApplicable, + "name.resource": notApplicable, + "name.variable.pattern": notApplicable, "namedFunction.iteration.block": notApplicable, "namedFunction.iteration.document": notApplicable, "section.iteration.document": notApplicable, From 8bd068f394644d8adcc1b35ab9698622c990c184 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 08:01:05 +0200 Subject: [PATCH 04/10] Add values --- ...rgument.formal.constructor.iteration.scope | 24 +++++++++++++ .../value.argument.formal.constructor.scope | 22 ++++++++++++ ...lue.argument.formal.method.iteration.scope | 24 +++++++++++++ .../csharp/value.argument.formal.method.scope | 22 ++++++++++++ data/fixtures/scopes/csharp/value.field.scope | 22 ++++++++++++ .../scopes/csharp/value.foreach.scope | 20 +++++++++++ .../scopes/csharp/value.return.lambda.scope | 20 +++++++++++ .../scopes/csharp/value.return.lambda2.scope | 22 ++++++++++++ .../fixtures/scopes/csharp/value.return.scope | 22 ++++++++++++ data/fixtures/scopes/csharp/value.yield.scope | 22 ++++++++++++ .../common/src/scopeSupportFacets/csharp.ts | 34 +++++++++++++++++-- queries/csharp.scm | 27 +++++++++++++++ 12 files changed, 278 insertions(+), 3 deletions(-) create mode 100644 data/fixtures/scopes/csharp/value.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/csharp/value.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/csharp/value.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/csharp/value.argument.formal.method.scope create mode 100644 data/fixtures/scopes/csharp/value.field.scope create mode 100644 data/fixtures/scopes/csharp/value.foreach.scope create mode 100644 data/fixtures/scopes/csharp/value.return.lambda.scope create mode 100644 data/fixtures/scopes/csharp/value.return.lambda2.scope create mode 100644 data/fixtures/scopes/csharp/value.return.scope create mode 100644 data/fixtures/scopes/csharp/value.yield.scope diff --git a/data/fixtures/scopes/csharp/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/csharp/value.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..e7cd07a8e1 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.argument.formal.constructor.iteration.scope @@ -0,0 +1,24 @@ +class MyClass { + MyClass(int a = 1, int b = 2) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| MyClass(int a = 1, int b = 2) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:12-1:32 + >--------------------< +1| MyClass(int a = 1, int b = 2) {} + + +[#3 Range] = +[#3 Domain] = 1:35-1:35 + >< +1| MyClass(int a = 1, int b = 2) {} diff --git a/data/fixtures/scopes/csharp/value.argument.formal.constructor.scope b/data/fixtures/scopes/csharp/value.argument.formal.constructor.scope new file mode 100644 index 0000000000..0cb76ed477 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.argument.formal.constructor.scope @@ -0,0 +1,22 @@ +class MyClass { + MyClass(int a = 1) {} +} +--- + +[Content] = 1:20-1:21 + >-< +1| MyClass(int a = 1) {} + +[Removal] = 1:17-1:21 + >----< +1| MyClass(int a = 1) {} + +[Leading delimiter] = 1:17-1:20 + >---< +1| MyClass(int a = 1) {} + +[Domain] = 1:12-1:21 + >---------< +1| MyClass(int a = 1) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/csharp/value.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..c96c7e651f --- /dev/null +++ b/data/fixtures/scopes/csharp/value.argument.formal.method.iteration.scope @@ -0,0 +1,24 @@ +class MyClass { + void funk(int a = 1, int b = 2) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| void funk(int a = 1, int b = 2) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:14-1:34 + >--------------------< +1| void funk(int a = 1, int b = 2) {} + + +[#3 Range] = +[#3 Domain] = 1:37-1:37 + >< +1| void funk(int a = 1, int b = 2) {} diff --git a/data/fixtures/scopes/csharp/value.argument.formal.method.scope b/data/fixtures/scopes/csharp/value.argument.formal.method.scope new file mode 100644 index 0000000000..bdff558cb2 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.argument.formal.method.scope @@ -0,0 +1,22 @@ +class MyClass { + void funk(int a = 1) {} +} +--- + +[Content] = 1:22-1:23 + >-< +1| void funk(int a = 1) {} + +[Removal] = 1:19-1:23 + >----< +1| void funk(int a = 1) {} + +[Leading delimiter] = 1:19-1:22 + >---< +1| void funk(int a = 1) {} + +[Domain] = 1:14-1:23 + >---------< +1| void funk(int a = 1) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.field.scope b/data/fixtures/scopes/csharp/value.field.scope new file mode 100644 index 0000000000..80a7d73d2f --- /dev/null +++ b/data/fixtures/scopes/csharp/value.field.scope @@ -0,0 +1,22 @@ +class MyClass { + int value = 2; +} +--- + +[Content] = 1:16-1:17 + >-< +1| int value = 2; + +[Removal] = 1:13-1:17 + >----< +1| int value = 2; + +[Leading delimiter] = 1:13-1:16 + >---< +1| int value = 2; + +[Domain] = 1:4-1:17 + >-------------< +1| int value = 2; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.foreach.scope b/data/fixtures/scopes/csharp/value.foreach.scope new file mode 100644 index 0000000000..1894ca1a2f --- /dev/null +++ b/data/fixtures/scopes/csharp/value.foreach.scope @@ -0,0 +1,20 @@ +foreach (int value in values) {} +--- + +[Content] = 0:22-0:28 + >------< +0| foreach (int value in values) {} + +[Removal] = 0:21-0:28 + >-------< +0| foreach (int value in values) {} + +[Leading delimiter] = 0:21-0:22 + >-< +0| foreach (int value in values) {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| foreach (int value in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.return.lambda.scope b/data/fixtures/scopes/csharp/value.return.lambda.scope new file mode 100644 index 0000000000..0d759fd8d3 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.return.lambda.scope @@ -0,0 +1,20 @@ +() => 2; +--- + +[Content] = 0:6-0:7 + >-< +0| () => 2; + +[Removal] = 0:5-0:7 + >--< +0| () => 2; + +[Leading delimiter] = 0:5-0:6 + >-< +0| () => 2; + +[Domain] = 0:0-0:7 + >-------< +0| () => 2; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.return.lambda2.scope b/data/fixtures/scopes/csharp/value.return.lambda2.scope new file mode 100644 index 0000000000..5dc35f18ef --- /dev/null +++ b/data/fixtures/scopes/csharp/value.return.lambda2.scope @@ -0,0 +1,22 @@ +() => { + return 2; +}; +--- + +[Content] = 1:11-1:12 + >-< +1| return 2; + +[Removal] = 1:10-1:12 + >--< +1| return 2; + +[Leading delimiter] = 1:10-1:11 + >-< +1| return 2; + +[Domain] = 1:4-1:13 + >---------< +1| return 2; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.return.scope b/data/fixtures/scopes/csharp/value.return.scope new file mode 100644 index 0000000000..77155463c2 --- /dev/null +++ b/data/fixtures/scopes/csharp/value.return.scope @@ -0,0 +1,22 @@ +int funk() { + return 2; +} +--- + +[Content] = 1:11-1:12 + >-< +1| return 2; + +[Removal] = 1:10-1:12 + >--< +1| return 2; + +[Leading delimiter] = 1:10-1:11 + >-< +1| return 2; + +[Domain] = 1:4-1:13 + >---------< +1| return 2; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/value.yield.scope b/data/fixtures/scopes/csharp/value.yield.scope new file mode 100644 index 0000000000..caef32a3cf --- /dev/null +++ b/data/fixtures/scopes/csharp/value.yield.scope @@ -0,0 +1,22 @@ +IEnumerable funk() { + yield return 2; +} +--- + +[Content] = 1:17-1:18 + >-< +1| yield return 2; + +[Removal] = 1:16-1:18 + >--< +1| yield return 2; + +[Leading delimiter] = 1:16-1:17 + >-< +1| yield return 2; + +[Domain] = 1:4-1:19 + >---------------< +1| yield return 2; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 7951b03562..28377586d9 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -71,12 +71,38 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "name.method": supported, "name.variable": supported, - "value.variable": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, + "value.argument.formal": supported, "value.assignment": supported, + "value.field": supported, + "value.foreach": supported, "value.mapPair": supported, "value.mapPair.iteration": supported, - "value.argument.formal": supported, - "value.argument.formal.iteration": supported, + "value.return.lambda": supported, + "value.return": supported, + "value.variable": supported, + "value.yield": supported, + + // "type.argument.formal": supported, + // "type.argument.formal.iteration": supported, + // "type.argument.formal.method": supported, + // "type.argument.formal.method.iteration": supported, + // "type.argument.formal.constructor": supported, + // "type.argument.formal.constructor.iteration": supported, + // "type.alias": supported, + // "type.cast": supported, + // "type.field": supported, + // "type.field.iteration": supported, + // "type.interface": supported, + // "type.enum": supported, + // "type.return": supported, + // "type.variable": supported, + // "type.typeArgument": supported, + // "type.typeArgument.iteration": supported, "type.variable": supported, "type.argument.formal": supported, @@ -155,6 +181,8 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, "textFragment.element": notApplicable, + "value.typeAlias": notApplicable, + "value.variable.pattern": notApplicable, command: notApplicable, element: notApplicable, endTag: notApplicable, diff --git a/queries/csharp.scm b/queries/csharp.scm index 37628c29b8..8129e9c0d5 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -126,6 +126,7 @@ ;;! ^^^^^ (for_each_statement left: (_) @name + right: (_) @value ) @_.domain ;;!! true ? 0 : 1; @@ -172,8 +173,34 @@ (comment) @comment @textFragment +;;!! () => {}; +;;! ^^^^^^^^ (lambda_expression) @anonymousFunction +;;!! () => 2; +;;! ^ +(lambda_expression + body: (_) @value + (#not-type? @value block) +) @_.domain + +;;!! return 2; +;;! ^ +(return_statement + (_) @value +) @_.domain + +;;!! yield return 2; +;;! ^ +(yield_statement + (_) @value +) @_.domain + +( + (return_statement) @_.iteration @value.iteration + (#document-range! @_.iteration @value.iteration) +) + (attribute) @attribute [ From d2a411793ad2c00a80ab30b200dbd483ff551b1d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 08:04:49 +0200 Subject: [PATCH 05/10] Clean up --- queries/csharp.scm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/queries/csharp.scm b/queries/csharp.scm index 8129e9c0d5..891964b0b6 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -161,16 +161,19 @@ ) ) +;;!! "Hello world" ( (string_literal) @string @textFragment (#child-range! @textFragment 0 -1 true true) ) +;;!! @"Hello world" ( (verbatim_string_literal) @string @textFragment (#character-range! @textFragment 2 -1) ) +;;!! // Hello world (comment) @comment @textFragment ;;!! () => {}; @@ -196,11 +199,8 @@ (_) @value ) @_.domain -( - (return_statement) @_.iteration @value.iteration - (#document-range! @_.iteration @value.iteration) -) - +;;!! [Obsolete("Deprecated")] +;;! ^^^^^^^^^^^^^^^^^^^^^^ (attribute) @attribute [ @@ -225,6 +225,7 @@ ) ) +;;!! void foo() {} [ (invocation_expression) (object_creation_expression) From a1045eafa314781b9482ce0445850ecc03e1f200 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 09:03:26 +0200 Subject: [PATCH 06/10] Added type --- ...rgument.formal.constructor.iteration.scope | 24 ++++++++ .../type.argument.formal.constructor.scope | 34 +++++++++++ ...ype.argument.formal.method.iteration.scope | 24 ++++++++ .../csharp/type.argument.formal.method.scope | 57 +++++++++++++++++++ data/fixtures/scopes/csharp/type.cast.scope | 16 ++++++ data/fixtures/scopes/csharp/type.class.scope | 10 ++++ data/fixtures/scopes/csharp/type.enum.scope | 10 ++++ .../scopes/csharp/type.field.iteration.scope | 7 +++ data/fixtures/scopes/csharp/type.field.scope | 38 +++++++++++++ .../fixtures/scopes/csharp/type.foreach.scope | 20 +++++++ .../scopes/csharp/type.interface.scope | 10 ++++ data/fixtures/scopes/csharp/type.return.scope | 20 +++++++ .../csharp/type.typeArgument.iteration.scope | 10 ++++ .../scopes/csharp/type.typeArgument.scope | 29 ++++++++++ .../java/type.typeArgument.iteration.scope | 7 ++- .../python/type.typeArgument.iteration.scope | 7 ++- .../type.typeArgument.iteration.scope | 7 ++- .../common/src/scopeSupportFacets/csharp.ts | 41 +++++++------ queries/csharp.scm | 38 ++++++++++++- queries/java.scm | 14 +---- queries/javascript.core.scm | 2 - queries/javascript.function.scm | 2 - queries/kotlin.scm | 5 +- queries/python.scm | 4 +- queries/scss.scm | 6 -- queries/typescript.core.scm | 6 +- 26 files changed, 388 insertions(+), 60 deletions(-) create mode 100644 data/fixtures/scopes/csharp/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/csharp/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/csharp/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/csharp/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/csharp/type.cast.scope create mode 100644 data/fixtures/scopes/csharp/type.class.scope create mode 100644 data/fixtures/scopes/csharp/type.enum.scope create mode 100644 data/fixtures/scopes/csharp/type.field.iteration.scope create mode 100644 data/fixtures/scopes/csharp/type.field.scope create mode 100644 data/fixtures/scopes/csharp/type.foreach.scope create mode 100644 data/fixtures/scopes/csharp/type.interface.scope create mode 100644 data/fixtures/scopes/csharp/type.return.scope create mode 100644 data/fixtures/scopes/csharp/type.typeArgument.iteration.scope create mode 100644 data/fixtures/scopes/csharp/type.typeArgument.scope diff --git a/data/fixtures/scopes/csharp/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/csharp/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..5f46efab43 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,24 @@ +class MyClass { + MyClass(int a, int b) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| MyClass(int a, int b) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:12-1:24 + >------------< +1| MyClass(int a, int b) {} + + +[#3 Range] = +[#3 Domain] = 1:27-1:27 + >< +1| MyClass(int a, int b) {} diff --git a/data/fixtures/scopes/csharp/type.argument.formal.constructor.scope b/data/fixtures/scopes/csharp/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..1709516671 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.argument.formal.constructor.scope @@ -0,0 +1,34 @@ +class MyClass { + MyClass(int a) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| MyClass(int a) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:12-1:15 + >---< +1| MyClass(int a) {} + +[#2 Removal] = 1:12-1:16 + >----< +1| MyClass(int a) {} + +[#2 Trailing delimiter] = 1:15-1:16 + >-< +1| MyClass(int a) {} + +[#2 Domain] = 1:12-1:17 + >-----< +1| MyClass(int a) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/csharp/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..9fd010aa96 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.argument.formal.method.iteration.scope @@ -0,0 +1,24 @@ +class MyClass { + void funk(int a, int b) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| void funk(int a, int b) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:14-1:26 + >------------< +1| void funk(int a, int b) {} + + +[#3 Range] = +[#3 Domain] = 1:29-1:29 + >< +1| void funk(int a, int b) {} diff --git a/data/fixtures/scopes/csharp/type.argument.formal.method.scope b/data/fixtures/scopes/csharp/type.argument.formal.method.scope new file mode 100644 index 0000000000..91ac9a42a8 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.argument.formal.method.scope @@ -0,0 +1,57 @@ +class MyClass { + void funk(int a) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| void funk(int a) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:8 + >----< +1| void funk(int a) {} + +[#2 Removal] = 1:4-1:9 + >-----< +1| void funk(int a) {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| void funk(int a) {} + +[#2 Trailing delimiter] = 1:8-1:9 + >-< +1| void funk(int a) {} + +[#2 Domain] = 1:4-1:23 + >-------------------< +1| void funk(int a) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:14-1:17 + >---< +1| void funk(int a) {} + +[#3 Removal] = 1:14-1:18 + >----< +1| void funk(int a) {} + +[#3 Trailing delimiter] = 1:17-1:18 + >-< +1| void funk(int a) {} + +[#3 Domain] = 1:14-1:19 + >-----< +1| void funk(int a) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.cast.scope b/data/fixtures/scopes/csharp/type.cast.scope new file mode 100644 index 0000000000..74cd6e837c --- /dev/null +++ b/data/fixtures/scopes/csharp/type.cast.scope @@ -0,0 +1,16 @@ +(int)5.5; +--- + +[Content] = 0:1-0:4 + >---< +0| (int)5.5; + +[Removal] = 0:0-0:5 + >-----< +0| (int)5.5; + +[Domain] = 0:0-0:8 + >--------< +0| (int)5.5; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.class.scope b/data/fixtures/scopes/csharp/type.class.scope new file mode 100644 index 0000000000..696dd5c641 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.class.scope @@ -0,0 +1,10 @@ +class MyClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.enum.scope b/data/fixtures/scopes/csharp/type.enum.scope new file mode 100644 index 0000000000..ffa3f8bbb0 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.enum.scope @@ -0,0 +1,10 @@ +enum State { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| enum State { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.field.iteration.scope b/data/fixtures/scopes/csharp/type.field.iteration.scope new file mode 100644 index 0000000000..4eaba49f3c --- /dev/null +++ b/data/fixtures/scopes/csharp/type.field.iteration.scope @@ -0,0 +1,7 @@ +class MyClass { } +--- + +[Range] = +[Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/csharp/type.field.scope b/data/fixtures/scopes/csharp/type.field.scope new file mode 100644 index 0000000000..6228c94197 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.field.scope @@ -0,0 +1,38 @@ +class MyClass { + int value; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| int value; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| int value; + +[#2 Removal] = 1:4-1:8 + >----< +1| int value; + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int value; + +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int value; + +[#2 Domain] = 1:4-1:13 + >---------< +1| int value; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.foreach.scope b/data/fixtures/scopes/csharp/type.foreach.scope new file mode 100644 index 0000000000..05dbc70579 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.foreach.scope @@ -0,0 +1,20 @@ +foreach (int value in values) {} +--- + +[Content] = 0:9-0:12 + >---< +0| foreach (int value in values) {} + +[Removal] = 0:9-0:13 + >----< +0| foreach (int value in values) {} + +[Trailing delimiter] = 0:12-0:13 + >-< +0| foreach (int value in values) {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| foreach (int value in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.interface.scope b/data/fixtures/scopes/csharp/type.interface.scope new file mode 100644 index 0000000000..fcc6af440a --- /dev/null +++ b/data/fixtures/scopes/csharp/type.interface.scope @@ -0,0 +1,10 @@ +interface IClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:20 + >--------------------< +0| interface IClass { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.return.scope b/data/fixtures/scopes/csharp/type.return.scope new file mode 100644 index 0000000000..30a50088ad --- /dev/null +++ b/data/fixtures/scopes/csharp/type.return.scope @@ -0,0 +1,20 @@ +int funk() {} +--- + +[Content] = 0:0-0:3 + >---< +0| int funk() {} + +[Removal] = 0:0-0:4 + >----< +0| int funk() {} + +[Trailing delimiter] = 0:3-0:4 + >-< +0| int funk() {} + +[Domain] = 0:0-0:13 + >-------------< +0| int funk() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope b/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..ab41990635 --- /dev/null +++ b/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope @@ -0,0 +1,10 @@ +Dictionary values; +--- + +[Range] = 0:11-0:22 + >-----------< +0| Dictionary values; + +[Domain] = 0:10-0:23 + >-------------< +0| Dictionary values; diff --git a/data/fixtures/scopes/csharp/type.typeArgument.scope b/data/fixtures/scopes/csharp/type.typeArgument.scope new file mode 100644 index 0000000000..8e2f5622bd --- /dev/null +++ b/data/fixtures/scopes/csharp/type.typeArgument.scope @@ -0,0 +1,29 @@ +List values; +--- + +[#1 Content] = 0:0-0:9 + >---------< +0| List values; + +[#1 Removal] = 0:0-0:10 + >----------< +0| List values; + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| List values; + +[#1 Domain] = 0:0-0:16 + >----------------< +0| List values; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:5-0:8 + >---< +0| List values; + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/type.typeArgument.iteration.scope b/data/fixtures/scopes/java/type.typeArgument.iteration.scope index f51d7acf21..e9322a1008 100644 --- a/data/fixtures/scopes/java/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/java/type.typeArgument.iteration.scope @@ -1,7 +1,10 @@ Map foo; --- -[Range] = -[Domain] = 0:4-0:12 +[Range] = 0:4-0:12 >--------< 0| Map foo; + +[Domain] = 0:3-0:13 + >----------< +0| Map foo; diff --git a/data/fixtures/scopes/python/type.typeArgument.iteration.scope b/data/fixtures/scopes/python/type.typeArgument.iteration.scope index 58ac26d611..c7a8c145b3 100644 --- a/data/fixtures/scopes/python/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/python/type.typeArgument.iteration.scope @@ -1,7 +1,10 @@ value: map[str, int] --- -[Range] = -[Domain] = 0:11-0:19 +[Range] = 0:11-0:19 >--------< 0| value: map[str, int] + +[Domain] = 0:10-0:20 + >----------< +0| value: map[str, int] diff --git a/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope b/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope index 11833db77c..6622bc559c 100644 --- a/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope @@ -7,7 +7,10 @@ let value: Map; 0| let value: Map; -[#2 Range] = -[#2 Domain] = 0:15-0:29 +[#2 Range] = 0:15-0:29 >--------------< 0| let value: Map; + +[#2 Domain] = 0:14-0:30 + >----------------< +0| let value: Map; diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 28377586d9..fd995bd186 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -87,26 +87,23 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": supported, "value.yield": supported, - // "type.argument.formal": supported, - // "type.argument.formal.iteration": supported, - // "type.argument.formal.method": supported, - // "type.argument.formal.method.iteration": supported, - // "type.argument.formal.constructor": supported, - // "type.argument.formal.constructor.iteration": supported, - // "type.alias": supported, - // "type.cast": supported, - // "type.field": supported, - // "type.field.iteration": supported, - // "type.interface": supported, - // "type.enum": supported, - // "type.return": supported, - // "type.variable": supported, - // "type.typeArgument": supported, - // "type.typeArgument.iteration": supported, - - "type.variable": supported, "type.argument.formal": supported, "type.argument.formal.iteration": supported, + "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, + "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, + "type.cast": supported, + "type.class": supported, + "type.foreach": supported, + "type.field": supported, + "type.field.iteration": supported, + "type.interface": supported, + "type.enum": supported, + "type.return": supported, + "type.variable": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, "key.mapPair": supported, "key.mapPair.iteration": supported, @@ -181,6 +178,14 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, "textFragment.element": notApplicable, + "type.resource.iteration": notApplicable, + "type.resource": notApplicable, + "type.alias": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + "value.attribute": notApplicable, + "value.resource.iteration": notApplicable, + "value.resource": notApplicable, "value.typeAlias": notApplicable, "value.variable.pattern": notApplicable, command: notApplicable, diff --git a/queries/csharp.scm b/queries/csharp.scm index 891964b0b6..5e140df220 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -140,9 +140,11 @@ alternative: (_) @branch ) @condition.domain +;;!! class Foo {} +;;! ^^^^^^^^^^^^ (class_declaration name: (identifier) @className -) @class @_.domain +) @class @type @_.domain ( (compilation_unit) @class.iteration @className.iteration @@ -361,10 +363,42 @@ name: (_) @name ) @_.domain -(_ +( + (_ + type: (_) @type + ) @_.domain + (#not-type? @_.domain cast_expression) +) + +;;!! (int)5.5; +;;! ^^^ +(cast_expression + "(" @type.removal.start type: (_) @type + ")" @type.removal.end ) @_.domain +;;!! enum Foo {} +;;!! interface IFoo {} +[ + (enum_declaration) + (interface_declaration) +] @type + +(type_argument_list + (_)? @_.leading.endOf + . + (_) @type + . + (_)? @_.trailing.startOf + (#insertion-delimiter! @type ", ") +) + +(type_argument_list + "<" @type.iteration.start.endOf + ">" @type.iteration.end.startOf +) @type.iteration.domain + ;;!! int value = 5 ;;! ^ (parameter diff --git a/queries/java.scm b/queries/java.scm index 5fae385b9d..ff5644c843 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -60,27 +60,21 @@ ;;!! class MyClass { } ;;! ^ (class_body - . "{" @class.iteration.start.endOf @className.iteration.start.endOf "}" @class.iteration.end.startOf @className.iteration.end.startOf - . ) (class_body - . "{" @type.iteration.start.endOf @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf "}" @type.iteration.end.startOf @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf - . ) ;;!! for (...) { } ;;! ^ (_ body: (_ - . "{" @name.iteration.start.endOf @statement.iteration.start.endOf "}" @name.iteration.end.startOf @statement.iteration.end.startOf - . ) ) @@ -88,10 +82,8 @@ ;;! ^ (if_statement (block - . "{" @name.iteration.start.endOf @statement.iteration.start.endOf "}" @name.iteration.end.startOf @statement.iteration.end.startOf - . ) ) @@ -300,10 +292,8 @@ ;;!! void myFunk(int value) {} ;;! ^^^^^^^^^ (formal_parameters - . "(" @type.iteration.start.endOf @name.iteration.start.endOf ")" @type.iteration.end.startOf @name.iteration.end.startOf - . ) @type.iteration.domain @name.iteration.domain ;;!! List list = value; @@ -495,11 +485,9 @@ ;;!! Map foo; ;;! ^^^^^^^^ (type_arguments - . "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf - . -) +) @type.iteration.domain ;;!! foo(name: string) {} ;;! ^^^^^^^^^^^^ diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index 2d016e475e..316263a0ea 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -432,10 +432,8 @@ ;;! *** (_ body: (_ - . "{" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf - . ) ) diff --git a/queries/javascript.function.scm b/queries/javascript.function.scm index 7a274bfcac..831d1dc155 100644 --- a/queries/javascript.function.scm +++ b/queries/javascript.function.scm @@ -171,10 +171,8 @@ ] @namedFunction.iteration @functionName.iteration (class_body - . "{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf "}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf - . ) ;;!! { funk: function() { } } diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 60b48b1087..582be892f3 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -102,8 +102,7 @@ ( "else" (control_structure_body) @branch.removal.end.startOf - ) -? + )? ) ;; Else-if branch @@ -384,10 +383,8 @@ (type_projection) @type ) (type_arguments - . "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf - . ) (anonymous_function diff --git a/queries/python.scm b/queries/python.scm index 3783d2d2a9..66b169e048 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -118,11 +118,9 @@ ;;! ------------- (generic_type (type_parameter - . "[" @type.iteration.start.endOf "]" @type.iteration.end.startOf - . - ) + ) @type.iteration.domain ) ;;!! def aaa() -> str: diff --git a/queries/scss.scm b/queries/scss.scm index 5673d1cbb9..53d624ecc2 100644 --- a/queries/scss.scm +++ b/queries/scss.scm @@ -67,18 +67,14 @@ (_ (parameters - . "(" @argumentOrParameter.iteration.start.endOf ")" @argumentOrParameter.iteration.end.startOf - . ) ) @argumentOrParameter.iteration.domain (parameters - . "(" @name.iteration.start.endOf @value.iteration.start.endOf ")" @name.iteration.end.startOf @value.iteration.end.startOf - . ) @name.iteration.domain @value.iteration.domain ;;!! foo($foo: 123) @@ -97,10 +93,8 @@ ) (block - . "{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf "}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf - . ) (binary_expression diff --git a/queries/typescript.core.scm b/queries/typescript.core.scm index 58ddad21f9..1eaf4e2a19 100644 --- a/queries/typescript.core.scm +++ b/queries/typescript.core.scm @@ -287,8 +287,8 @@ "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf . - ) @_dummy - (#not-parent-type? @_dummy type_assertion) + ) @type.iteration.domain + (#not-parent-type? @type.iteration.domain type_assertion) ) ;;!! function foo() {} @@ -427,8 +427,6 @@ ;;!! class Aaa { } ;;! ^ (class_body - . "{" @type.iteration.start.endOf "}" @type.iteration.end.startOf - . ) From f839241b830bec366ec6736e68559b7f7b8bdc3e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 09:09:05 +0200 Subject: [PATCH 07/10] Up dit test --- data/fixtures/scopes/java/type.field.iteration.scope | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/fixtures/scopes/java/type.field.iteration.scope b/data/fixtures/scopes/java/type.field.iteration.scope index 1aa65a64ac..36371abf38 100644 --- a/data/fixtures/scopes/java/type.field.iteration.scope +++ b/data/fixtures/scopes/java/type.field.iteration.scope @@ -12,7 +12,10 @@ class MyClass { < -[#2 Range] = -[#2 Domain] = 1:8-1:16 +[#2 Range] = 1:8-1:16 >--------< 1| Map foo; + +[#2 Domain] = 1:7-1:17 + >----------< +1| Map foo; From 3ef4817a7ff47de1d345cf4e0c8110ae1bc8f425 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 18:25:06 +0200 Subject: [PATCH 08/10] Update queries/kotlin.scm --- queries/kotlin.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 582be892f3..a215d8fa45 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -102,7 +102,7 @@ ( "else" (control_structure_body) @branch.removal.end.startOf - )? + ) ) ;; Else-if branch From 602d0a773d544cccf1796a5a35f33b8a70136196 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 18:25:42 +0200 Subject: [PATCH 09/10] Update queries/kotlin.scm --- queries/kotlin.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/kotlin.scm b/queries/kotlin.scm index a215d8fa45..582be892f3 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -102,7 +102,7 @@ ( "else" (control_structure_body) @branch.removal.end.startOf - ) + )? ) ;; Else-if branch From 2d9edeb2d5bfeb144f8ad2acdd4137e63527dd39 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 May 2025 19:05:03 +0200 Subject: [PATCH 10/10] Update iteration scope domain --- .../scopes/csharp/type.typeArgument.iteration.scope | 7 ++----- data/fixtures/scopes/java/type.field.iteration.scope | 7 ++----- .../fixtures/scopes/java/type.typeArgument.iteration.scope | 7 ++----- .../scopes/python/type.typeArgument.iteration.scope | 7 ++----- .../typescript.core/type.typeArgument.iteration.scope | 7 ++----- queries/csharp.scm | 4 +++- queries/java.scm | 2 +- queries/python.scm | 2 +- queries/typescript.core.scm | 4 ++-- 9 files changed, 17 insertions(+), 30 deletions(-) diff --git a/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope b/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope index ab41990635..68b192c991 100644 --- a/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/csharp/type.typeArgument.iteration.scope @@ -1,10 +1,7 @@ Dictionary values; --- -[Range] = 0:11-0:22 +[Range] = +[Domain] = 0:11-0:22 >-----------< 0| Dictionary values; - -[Domain] = 0:10-0:23 - >-------------< -0| Dictionary values; diff --git a/data/fixtures/scopes/java/type.field.iteration.scope b/data/fixtures/scopes/java/type.field.iteration.scope index 36371abf38..1aa65a64ac 100644 --- a/data/fixtures/scopes/java/type.field.iteration.scope +++ b/data/fixtures/scopes/java/type.field.iteration.scope @@ -12,10 +12,7 @@ class MyClass { < -[#2 Range] = 1:8-1:16 +[#2 Range] = +[#2 Domain] = 1:8-1:16 >--------< 1| Map foo; - -[#2 Domain] = 1:7-1:17 - >----------< -1| Map foo; diff --git a/data/fixtures/scopes/java/type.typeArgument.iteration.scope b/data/fixtures/scopes/java/type.typeArgument.iteration.scope index e9322a1008..f51d7acf21 100644 --- a/data/fixtures/scopes/java/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/java/type.typeArgument.iteration.scope @@ -1,10 +1,7 @@ Map foo; --- -[Range] = 0:4-0:12 +[Range] = +[Domain] = 0:4-0:12 >--------< 0| Map foo; - -[Domain] = 0:3-0:13 - >----------< -0| Map foo; diff --git a/data/fixtures/scopes/python/type.typeArgument.iteration.scope b/data/fixtures/scopes/python/type.typeArgument.iteration.scope index c7a8c145b3..58ac26d611 100644 --- a/data/fixtures/scopes/python/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/python/type.typeArgument.iteration.scope @@ -1,10 +1,7 @@ value: map[str, int] --- -[Range] = 0:11-0:19 +[Range] = +[Domain] = 0:11-0:19 >--------< 0| value: map[str, int] - -[Domain] = 0:10-0:20 - >----------< -0| value: map[str, int] diff --git a/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope b/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope index 6622bc559c..11833db77c 100644 --- a/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/typescript.core/type.typeArgument.iteration.scope @@ -7,10 +7,7 @@ let value: Map; 0| let value: Map; -[#2 Range] = 0:15-0:29 +[#2 Range] = +[#2 Domain] = 0:15-0:29 >--------------< 0| let value: Map; - -[#2 Domain] = 0:14-0:30 - >----------------< -0| let value: Map; diff --git a/queries/csharp.scm b/queries/csharp.scm index 5e140df220..d739eb687b 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -385,6 +385,8 @@ (interface_declaration) ] @type +;; Dictionary values; +;;! ^^^^^^ ^^^ (type_argument_list (_)? @_.leading.endOf . @@ -397,7 +399,7 @@ (type_argument_list "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf -) @type.iteration.domain +) ;;!! int value = 5 ;;! ^ diff --git a/queries/java.scm b/queries/java.scm index ff5644c843..c898bcfbcc 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -487,7 +487,7 @@ (type_arguments "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf -) @type.iteration.domain +) ;;!! foo(name: string) {} ;;! ^^^^^^^^^^^^ diff --git a/queries/python.scm b/queries/python.scm index 66b169e048..cf28622272 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -120,7 +120,7 @@ (type_parameter "[" @type.iteration.start.endOf "]" @type.iteration.end.startOf - ) @type.iteration.domain + ) ) ;;!! def aaa() -> str: diff --git a/queries/typescript.core.scm b/queries/typescript.core.scm index 1eaf4e2a19..2b792cd352 100644 --- a/queries/typescript.core.scm +++ b/queries/typescript.core.scm @@ -287,8 +287,8 @@ "<" @type.iteration.start.endOf ">" @type.iteration.end.startOf . - ) @type.iteration.domain - (#not-parent-type? @type.iteration.domain type_assertion) + ) @_dummy + (#not-parent-type? @_dummy type_assertion) ) ;;!! function foo() {}