From 35cbef9cc4d8ef8cb3bb385e76cf3d1a8b6468d9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Jun 2025 13:03:18 +0200 Subject: [PATCH 1/3] Started working on csharp interior scopes --- .../scopes/csharp/interior.class.scope | 2 ++ .../scopes/csharp/interior.function.scope | 2 ++ data/fixtures/scopes/csharp/interior.if.scope | 4 ++++ .../scopes/csharp/interior.lambda.scope | 2 ++ .../scopes/csharp/interior.lambda2.scope | 2 ++ .../scopes/csharp/interior.loop.scope | 2 ++ .../scopes/csharp/interior.loop2.scope | 2 ++ .../scopes/csharp/interior.loop3.scope | 2 ++ .../scopes/csharp/interior.loop4.scope | 2 ++ .../scopes/csharp/interior.switchCase.scope | 11 ++++++++++ .../scopes/csharp/interior.ternary.scope | 2 ++ .../fixtures/scopes/csharp/interior.try.scope | 3 +++ .../common/src/scopeSupportFacets/csharp.ts | 20 +++++++++---------- queries/csharp.scm | 12 ++++++----- 14 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 data/fixtures/scopes/csharp/interior.class.scope create mode 100644 data/fixtures/scopes/csharp/interior.function.scope create mode 100644 data/fixtures/scopes/csharp/interior.if.scope create mode 100644 data/fixtures/scopes/csharp/interior.lambda.scope create mode 100644 data/fixtures/scopes/csharp/interior.lambda2.scope create mode 100644 data/fixtures/scopes/csharp/interior.loop.scope create mode 100644 data/fixtures/scopes/csharp/interior.loop2.scope create mode 100644 data/fixtures/scopes/csharp/interior.loop3.scope create mode 100644 data/fixtures/scopes/csharp/interior.loop4.scope create mode 100644 data/fixtures/scopes/csharp/interior.switchCase.scope create mode 100644 data/fixtures/scopes/csharp/interior.ternary.scope create mode 100644 data/fixtures/scopes/csharp/interior.try.scope diff --git a/data/fixtures/scopes/csharp/interior.class.scope b/data/fixtures/scopes/csharp/interior.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/data/fixtures/scopes/csharp/interior.function.scope b/data/fixtures/scopes/csharp/interior.function.scope new file mode 100644 index 0000000000..4f48ff6fe0 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.function.scope @@ -0,0 +1,2 @@ +void Foo() { } +--- diff --git a/data/fixtures/scopes/csharp/interior.if.scope b/data/fixtures/scopes/csharp/interior.if.scope new file mode 100644 index 0000000000..899132d99b --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.if.scope @@ -0,0 +1,4 @@ +if (true) { } +else if (false) { } +else { } +--- diff --git a/data/fixtures/scopes/csharp/interior.lambda.scope b/data/fixtures/scopes/csharp/interior.lambda.scope new file mode 100644 index 0000000000..1a90180616 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.lambda.scope @@ -0,0 +1,2 @@ +() => 0; +--- diff --git a/data/fixtures/scopes/csharp/interior.lambda2.scope b/data/fixtures/scopes/csharp/interior.lambda2.scope new file mode 100644 index 0000000000..0e6f136968 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.lambda2.scope @@ -0,0 +1,2 @@ +() => { }; +--- diff --git a/data/fixtures/scopes/csharp/interior.loop.scope b/data/fixtures/scopes/csharp/interior.loop.scope new file mode 100644 index 0000000000..20d4face26 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.loop.scope @@ -0,0 +1,2 @@ +while (true) { } +--- diff --git a/data/fixtures/scopes/csharp/interior.loop2.scope b/data/fixtures/scopes/csharp/interior.loop2.scope new file mode 100644 index 0000000000..d5873abed6 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.loop2.scope @@ -0,0 +1,2 @@ +do { } while (true); +--- diff --git a/data/fixtures/scopes/csharp/interior.loop3.scope b/data/fixtures/scopes/csharp/interior.loop3.scope new file mode 100644 index 0000000000..1e67dc9b48 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.loop3.scope @@ -0,0 +1,2 @@ +for (int i = 0; i < size; ++i) { } +--- diff --git a/data/fixtures/scopes/csharp/interior.loop4.scope b/data/fixtures/scopes/csharp/interior.loop4.scope new file mode 100644 index 0000000000..c3699e8e3c --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.loop4.scope @@ -0,0 +1,2 @@ +foreach (int v in values) { } +--- diff --git a/data/fixtures/scopes/csharp/interior.switchCase.scope b/data/fixtures/scopes/csharp/interior.switchCase.scope new file mode 100644 index 0000000000..b7539509cc --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.switchCase.scope @@ -0,0 +1,11 @@ +switch (aaa) { + case 0: + foo; + break; + case 1: { + break; + } + default: + break; +} +--- diff --git a/data/fixtures/scopes/csharp/interior.ternary.scope b/data/fixtures/scopes/csharp/interior.ternary.scope new file mode 100644 index 0000000000..443315a4d7 --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.ternary.scope @@ -0,0 +1,2 @@ +true ? 1 : 0; +--- diff --git a/data/fixtures/scopes/csharp/interior.try.scope b/data/fixtures/scopes/csharp/interior.try.scope new file mode 100644 index 0000000000..de359f9c6e --- /dev/null +++ b/data/fixtures/scopes/csharp/interior.try.scope @@ -0,0 +1,3 @@ +try { } +catch(final Exception ex) { } +--- diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index be75bf962a..0f5cb23cb6 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, unsupported, notApplicable } = ScopeSupportFacetLevel; +const { supported, notApplicable } = ScopeSupportFacetLevel; export const csharpScopeSupport: LanguageScopeSupportFacetMap = { switchStatementSubject: supported, @@ -160,16 +160,14 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "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, + "interior.class": supported, + "interior.function": supported, + "interior.if": supported, + "interior.lambda": supported, + "interior.loop": supported, + "interior.switchCase": supported, + "interior.ternary": supported, + "interior.try": supported, // Not applicable diff --git a/queries/csharp.scm b/queries/csharp.scm index 6c5f1a49aa..4f86593ed9 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -144,6 +144,10 @@ ;;! ^^^^^^^^^^^^ (class_declaration name: (identifier) @className + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) ) @class @type @_.domain ( @@ -156,12 +160,10 @@ ;;! *** (_ body: (_ - . - "{" @class.iteration.start.endOf @className.iteration.start.endOf - "}" @class.iteration.end.startOf @className.iteration.end.startOf - . + "{" @class.iteration.start.endOf @className.iteration.start.endOf @interior.start.endOf + "}" @class.iteration.end.startOf @className.iteration.end.startOf @interior.end.startOf ) -) +) @interior.domain ;;!! "Hello world" ( From d7bf4a066510fbf181fb24c7f5a6ac5ba5e34816 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Jun 2025 13:06:37 +0200 Subject: [PATCH 2/3] Tests --- .../scopes/csharp/interior.class.scope | 23 ++++++++++++ .../scopes/csharp/interior.function.scope | 35 +++++++++++++++++++ .../scopes/csharp/interior.lambda2.scope | 35 +++++++++++++++++++ .../scopes/csharp/interior.loop.scope | 23 ++++++++++++ .../scopes/csharp/interior.loop3.scope | 35 +++++++++++++++++++ .../scopes/csharp/interior.loop4.scope | 35 +++++++++++++++++++ 6 files changed, 186 insertions(+) diff --git a/data/fixtures/scopes/csharp/interior.class.scope b/data/fixtures/scopes/csharp/interior.class.scope index 287f9b0c16..5390112f29 100644 --- a/data/fixtures/scopes/csharp/interior.class.scope +++ b/data/fixtures/scopes/csharp/interior.class.scope @@ -1,2 +1,25 @@ class Foo { } --- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#2 Domain] = 0:10-0:13 + >---< +0| class Foo { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.function.scope b/data/fixtures/scopes/csharp/interior.function.scope index 4f48ff6fe0..1c8b29392b 100644 --- a/data/fixtures/scopes/csharp/interior.function.scope +++ b/data/fixtures/scopes/csharp/interior.function.scope @@ -1,2 +1,37 @@ void Foo() { } --- + +[#1 Content] = +[#1 Removal] = 0:12-0:13 + >-< +0| void Foo() { } + +[#1 Domain] = 0:0-0:14 + >--------------< +0| void Foo() { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:9-0:9 + >< +0| void Foo() { } + +[#2 Domain] = 0:8-0:10 + >--< +0| void Foo() { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:12-0:13 + >-< +0| void Foo() { } + +[#3 Domain] = 0:11-0:14 + >---< +0| void Foo() { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.lambda2.scope b/data/fixtures/scopes/csharp/interior.lambda2.scope index 0e6f136968..ef5ef5acf1 100644 --- a/data/fixtures/scopes/csharp/interior.lambda2.scope +++ b/data/fixtures/scopes/csharp/interior.lambda2.scope @@ -1,2 +1,37 @@ () => { }; --- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () => { }; + +[#1 Domain] = 0:0-0:2 + >--< +0| () => { }; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:7-0:8 + >-< +0| () => { }; + +[#2 Domain] = 0:0-0:9 + >---------< +0| () => { }; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:7-0:8 + >-< +0| () => { }; + +[#3 Domain] = 0:6-0:9 + >---< +0| () => { }; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.loop.scope b/data/fixtures/scopes/csharp/interior.loop.scope index 20d4face26..0fe48d4d34 100644 --- a/data/fixtures/scopes/csharp/interior.loop.scope +++ b/data/fixtures/scopes/csharp/interior.loop.scope @@ -1,2 +1,25 @@ while (true) { } --- + +[#1 Content] = +[#1 Removal] = 0:7-0:11 + >----< +0| while (true) { } + +[#1 Domain] = 0:6-0:12 + >------< +0| while (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:14-0:15 + >-< +0| while (true) { } + +[#2 Domain] = 0:13-0:16 + >---< +0| while (true) { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.loop3.scope b/data/fixtures/scopes/csharp/interior.loop3.scope index 1e67dc9b48..e1cf88df36 100644 --- a/data/fixtures/scopes/csharp/interior.loop3.scope +++ b/data/fixtures/scopes/csharp/interior.loop3.scope @@ -1,2 +1,37 @@ for (int i = 0; i < size; ++i) { } --- + +[#1 Content] = +[#1 Removal] = 0:32-0:33 + >-< +0| for (int i = 0; i < size; ++i) { } + +[#1 Domain] = 0:0-0:34 + >----------------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:29 + >------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#2 Domain] = 0:4-0:30 + >--------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:32-0:33 + >-< +0| for (int i = 0; i < size; ++i) { } + +[#3 Domain] = 0:31-0:34 + >---< +0| for (int i = 0; i < size; ++i) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.loop4.scope b/data/fixtures/scopes/csharp/interior.loop4.scope index c3699e8e3c..13e6cbc8e7 100644 --- a/data/fixtures/scopes/csharp/interior.loop4.scope +++ b/data/fixtures/scopes/csharp/interior.loop4.scope @@ -1,2 +1,37 @@ foreach (int v in values) { } --- + +[#1 Content] = +[#1 Removal] = 0:27-0:28 + >-< +0| foreach (int v in values) { } + +[#1 Domain] = 0:0-0:29 + >-----------------------------< +0| foreach (int v in values) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:9-0:24 + >---------------< +0| foreach (int v in values) { } + +[#2 Domain] = 0:8-0:25 + >-----------------< +0| foreach (int v in values) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:27-0:28 + >-< +0| foreach (int v in values) { } + +[#3 Domain] = 0:26-0:29 + >---< +0| foreach (int v in values) { } + +[#3 Insertion delimiter] = " " From 20f469a3a0e13d6172e4bb5ad84eeb8788494d63 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Jun 2025 15:42:48 +0200 Subject: [PATCH 3/3] More scopes --- data/fixtures/scopes/csharp/interior.if.scope | 95 ++++++++++ .../scopes/csharp/interior.lambda.scope | 23 +++ .../scopes/csharp/interior.loop2.scope | 35 ++++ .../scopes/csharp/interior.switchCase.scope | 170 ++++++++++++++++++ .../scopes/csharp/interior.ternary.scope | 26 +++ .../fixtures/scopes/csharp/interior.try.scope | 86 ++++++++- queries/csharp.scm | 100 +++++++++-- 7 files changed, 517 insertions(+), 18 deletions(-) diff --git a/data/fixtures/scopes/csharp/interior.if.scope b/data/fixtures/scopes/csharp/interior.if.scope index 899132d99b..52ac91931a 100644 --- a/data/fixtures/scopes/csharp/interior.if.scope +++ b/data/fixtures/scopes/csharp/interior.if.scope @@ -2,3 +2,98 @@ if (true) { } else if (false) { } else { } --- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:8 + >----< +0| if (true) { } + +[#2 Domain] = 0:3-0:9 + >------< +0| if (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#3 Domain] = 0:10-0:13 + >---< +0| if (true) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#4 Domain] = 1:0-1:19 + >-------------------< +1| else if (false) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:9-1:14 + >-----< +1| else if (false) { } + +[#5 Domain] = 1:8-1:15 + >-------< +1| else if (false) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#6 Domain] = 1:16-1:19 + >---< +1| else if (false) { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:6-2:7 + >-< +2| else { } + +[#7 Domain] = 2:0-2:8 + >--------< +2| else { } + +[#7 Insertion delimiter] = " " + + +[#8 Content] = +[#8 Removal] = 2:6-2:7 + >-< +2| else { } + +[#8 Domain] = 2:5-2:8 + >---< +2| else { } + +[#8 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.lambda.scope b/data/fixtures/scopes/csharp/interior.lambda.scope index 1a90180616..6d85ffaf2f 100644 --- a/data/fixtures/scopes/csharp/interior.lambda.scope +++ b/data/fixtures/scopes/csharp/interior.lambda.scope @@ -1,2 +1,25 @@ () => 0; --- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () => 0; + +[#1 Domain] = 0:0-0:2 + >--< +0| () => 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:6-0:7 + >-< +0| () => 0; + +[#2 Domain] = 0:0-0:7 + >-------< +0| () => 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.loop2.scope b/data/fixtures/scopes/csharp/interior.loop2.scope index d5873abed6..d1833e59d1 100644 --- a/data/fixtures/scopes/csharp/interior.loop2.scope +++ b/data/fixtures/scopes/csharp/interior.loop2.scope @@ -1,2 +1,37 @@ do { } while (true); --- + +[#1 Content] = +[#1 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#1 Domain] = 0:0-0:20 + >--------------------< +0| do { } while (true); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#2 Domain] = 0:3-0:6 + >---< +0| do { } while (true); + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:14-0:18 + >----< +0| do { } while (true); + +[#3 Domain] = 0:13-0:19 + >------< +0| do { } while (true); + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.switchCase.scope b/data/fixtures/scopes/csharp/interior.switchCase.scope index b7539509cc..c0c5b32760 100644 --- a/data/fixtures/scopes/csharp/interior.switchCase.scope +++ b/data/fixtures/scopes/csharp/interior.switchCase.scope @@ -9,3 +9,173 @@ switch (aaa) { break; } --- + +[#1 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#1 Removal] = 0:14-9:0 + > +0| switch (aaa) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#1 Domain] = 0:0-9:1 + >-------------- +0| switch (aaa) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:8-0:11 + >---< +0| switch (aaa) { + +[#2 Domain] = 0:7-0:12 + >-----< +0| switch (aaa) { + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#3 Removal] = 0:14-9:0 + > +0| switch (aaa) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#3 Domain] = 0:13-9:1 + >- +0| switch (aaa) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 2:8-3:14 + >---- +2| foo; +3| break; + --------------< + +[#4 Domain] = 1:4-3:14 + >------- +1| case 0: +2| foo; +3| break; + --------------< + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 5:8-5:14 + >------< +5| break; + +[#5 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#5 Domain] = 4:4-6:5 + >--------- +4| case 1: { +5| break; +6| } + -----< + +[#5 Insertion delimiter] = " " + + +[#6 Content] = 5:8-5:14 + >------< +5| break; + +[#6 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#6 Domain] = 4:12-6:5 + >- +4| case 1: { +5| break; +6| } + -----< + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 8:8-8:14 + >------< +8| break; + +[#7 Domain] = 7:4-8:14 + >-------- +7| default: +8| break; + --------------< + +[#7 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.ternary.scope b/data/fixtures/scopes/csharp/interior.ternary.scope index 443315a4d7..79ef01735b 100644 --- a/data/fixtures/scopes/csharp/interior.ternary.scope +++ b/data/fixtures/scopes/csharp/interior.ternary.scope @@ -1,2 +1,28 @@ true ? 1 : 0; --- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:4 + >----< +0| true ? 1 : 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:7-0:8 + >-< +0| true ? 1 : 0; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 0:11-0:12 + >-< +0| true ? 1 : 0; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/csharp/interior.try.scope b/data/fixtures/scopes/csharp/interior.try.scope index de359f9c6e..87dc4ae08a 100644 --- a/data/fixtures/scopes/csharp/interior.try.scope +++ b/data/fixtures/scopes/csharp/interior.try.scope @@ -1,3 +1,87 @@ try { } -catch(final Exception ex) { } +catch(Exception ex) { } +finally { } --- + +[#1 Content] = +[#1 Removal] = 0:5-0:6 + >-< +0| try { } + +[#1 Domain] = 0:0-0:7 + >-------< +0| try { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:6 + >-< +0| try { } + +[#2 Domain] = 0:4-0:7 + >---< +0| try { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:21-1:22 + >-< +1| catch(Exception ex) { } + +[#3 Domain] = 1:0-1:23 + >-----------------------< +1| catch(Exception ex) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:6-1:18 + >------------< +1| catch(Exception ex) { } + +[#4 Domain] = 1:5-1:19 + >--------------< +1| catch(Exception ex) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:21-1:22 + >-< +1| catch(Exception ex) { } + +[#5 Domain] = 1:20-1:23 + >---< +1| catch(Exception ex) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#6 Domain] = 2:0-2:11 + >-----------< +2| finally { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#7 Domain] = 2:8-2:11 + >---< +2| finally { } + +[#7 Insertion delimiter] = " " diff --git a/queries/csharp.scm b/queries/csharp.scm index 4f86593ed9..326f17d4b3 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -72,22 +72,37 @@ ) @branch.start.startOf @branch.removal.start.startOf @condition.domain (#not-parent-type? @condition.domain "if_statement") ) +( + (if_statement + consequence: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @interior.domain.end.endOf + ) @interior.domain.start.startOf + (#not-parent-type? @interior.domain.start.startOf "if_statement") +) ;;!! else if () {} ;;! ^^^^^^^^^^^^^ (if_statement - "else" @branch.start.startOf @condition.domain.start.startOf + "else" @branch.start.startOf @interior.domain.start.startOf @condition.domain.start.startOf (if_statement condition: (_) @condition - consequence: (_) @branch.end.endOf @condition.domain.end.endOf + consequence: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end.endOf @interior.domain.end.endOf @condition.domain.end.endOf ) ) ;;!! else {} ;;! ^^^^^^^ (if_statement - "else" @branch.start - alternative: (block) @branch.end + "else" @branch.start @interior.domain.start.startOf + alternative: (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @interior.domain.end.endOf ) ;;!! if () {} else if () {} else {} @@ -100,8 +115,11 @@ ;;!! try () {} ;;! ^^^^^^^^^ (try_statement - body: (_) @branch.end.endOf -) @branch.start.startOf + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end.endOf @interior.domain.end.endOf +) @branch.start.startOf @interior.domain.start.startOf ;;!! catch () {} ;;! ^^^^^^^^^^^ @@ -109,7 +127,12 @@ ;;!! finally {} ;;! ^^^^^^^^^^ -(finally_clause) @branch +(finally_clause + (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @branch @interior.domain ;;!! try () {} catch () {} finally {} ;;! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,12 +156,14 @@ ;;! ^^^^ ;;! ^ ^ (conditional_expression - condition: (_) @condition - consequence: (_) @branch + condition: (_) @condition @interior ) @condition.domain (conditional_expression - alternative: (_) @branch -) @condition.domain + consequence: (_) @branch @interior +) +(conditional_expression + alternative: (_) @branch @interior +) ;;!! class Foo {} ;;! ^^^^^^^^^^^^ @@ -160,10 +185,20 @@ ;;! *** (_ body: (_ - "{" @class.iteration.start.endOf @className.iteration.start.endOf @interior.start.endOf - "}" @class.iteration.end.startOf @className.iteration.end.startOf @interior.end.startOf + "{" @class.iteration.start.endOf @className.iteration.start.endOf + "}" @class.iteration.end.startOf @className.iteration.end.startOf ) -) @interior.domain +) + +( + (_ + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) + ) @_.domain + (#not-type? @_.domain try_statement) +) ;;!! "Hello world" ( @@ -187,8 +222,8 @@ ;;!! () => 2; ;;! ^ (lambda_expression - body: (_) @value - (#not-type? @value block) + body: (_) @value @interior + (#not-type? @value block initializer_expression) ) @_.domain ;;!! return 2; @@ -262,11 +297,21 @@ ) @_.domain (do_statement + (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) "while" . (_) @condition ) @_.domain +;;!! case 0: break; +;;! ^^^^^^^^^^^^^^ +(switch_section) @branch + +;;!! case 0: break; +;;! ^ (switch_section (case_switch_label . @@ -274,7 +319,28 @@ ) ) @_.domain -(switch_section) @branch +;;!! default: break; +;;! ^^^^^^ +(switch_section + [ + (case_switch_label) + (default_switch_label) + ] + . + (_) @interior.start + (_)? @interior.end + . + (#not-type? @interior.start "block") +) @_.domain + +;;!! case 0: { } +;;! ^ +(switch_section + (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @_.domain (switch_statement body: (switch_body