From ee663e5cf0cc78265861c58950fe915df600bffb Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 8 Jun 2025 11:54:42 +0200 Subject: [PATCH 1/2] Recorded more scope tests --- .../c/argumentList.actual.method.empty.scope | 13 +++ ...argumentList.actual.method.multiLine.scope | 24 ++++ ...rgumentList.actual.method.singleLine.scope | 13 +++ ...rgument.actual.constructor.iteration.scope | 10 ++ .../cpp/argument.actual.constructor.scope | 33 ++++++ ...rgument.formal.constructor.iteration.scope | 12 ++ .../cpp/argument.formal.constructor.scope | 35 ++++++ .../argument.formal.lambda.iteration.scope | 10 ++ .../scopes/cpp/argument.formal.lambda.scope | 33 ++++++ .../argument.formal.method.iteration.scope | 12 ++ .../scopes/cpp/argument.formal.method.scope | 35 ++++++ ...rgumentList.actual.constructor.empty.scope | 13 +++ ...entList.actual.constructor.multiLine.scope | 24 ++++ ...ntList.actual.constructor.singleLine.scope | 13 +++ ...rgumentList.formal.constructor.empty.scope | 15 +++ ...entList.formal.constructor.multiLine.scope | 26 +++++ ...ntList.formal.constructor.singleLine.scope | 15 +++ .../argumentList.formal.lambda.empty.scope | 13 +++ ...argumentList.formal.lambda.multiLine.scope | 24 ++++ ...rgumentList.formal.lambda.singleLine.scope | 13 +++ .../argumentList.formal.method.empty.scope | 15 +++ ...argumentList.formal.method.multiLine.scope | 26 +++++ ...rgumentList.formal.method.singleLine.scope | 15 +++ .../scopes/cpp/name.constructor.scope | 45 ++++++++ .../scopes/cpp/name.constructor2.scope | 45 ++++++++ data/fixtures/scopes/cpp/name.method.scope | 45 ++++++++ .../scopes/cpp/switchStatementSubject.scope | 13 +++ ...rgument.formal.constructor.iteration.scope | 18 +++ ...ype.argument.formal.method.iteration.scope | 18 +++ .../scopes/cpp/value.return.lambda.scope | 22 ++++ packages/common/src/scopeSupportFacets/c.ts | 14 +-- packages/common/src/scopeSupportFacets/cpp.ts | 103 ++++++++---------- .../scopeSupportFacetInfos.ts | 10 +- queries/c.scm | 2 +- queries/cpp.scm | 2 + 35 files changed, 710 insertions(+), 69 deletions(-) create mode 100644 data/fixtures/scopes/c/argumentList.actual.method.empty.scope create mode 100644 data/fixtures/scopes/c/argumentList.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/c/argumentList.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/cpp/argument.actual.constructor.iteration.scope create mode 100644 data/fixtures/scopes/cpp/argument.actual.constructor.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/cpp/argument.formal.method.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.actual.constructor.empty.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.constructor.empty.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.lambda.empty.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.method.empty.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/cpp/argumentList.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/cpp/name.constructor.scope create mode 100644 data/fixtures/scopes/cpp/name.constructor2.scope create mode 100644 data/fixtures/scopes/cpp/name.method.scope create mode 100644 data/fixtures/scopes/cpp/switchStatementSubject.scope create mode 100644 data/fixtures/scopes/cpp/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/cpp/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/cpp/value.return.lambda.scope diff --git a/data/fixtures/scopes/c/argumentList.actual.method.empty.scope b/data/fixtures/scopes/c/argumentList.actual.method.empty.scope new file mode 100644 index 0000000000..91d34a15d7 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.method.empty.scope @@ -0,0 +1,13 @@ +foo.bar(); +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| foo.bar(); + +[Domain] = 0:0-0:9 + >---------< +0| foo.bar(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/c/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/c/argumentList.actual.method.multiLine.scope new file mode 100644 index 0000000000..7737c24c37 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.method.multiLine.scope @@ -0,0 +1,24 @@ +foo.bar( + int aaa, + int bbb +); +--- + +[Content] = +[Removal] = 0:8-3:0 + > +0| foo.bar( +1| int aaa, +2| int bbb +3| ); + < + +[Domain] = 0:0-3:1 + >-------- +0| foo.bar( +1| int aaa, +2| int bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/c/argumentList.actual.method.singleLine.scope b/data/fixtures/scopes/c/argumentList.actual.method.singleLine.scope new file mode 100644 index 0000000000..e0bee62c1c --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.method.singleLine.scope @@ -0,0 +1,13 @@ +foo.bar(int aaa, int bbb); +--- + +[Content] = +[Removal] = 0:8-0:24 + >----------------< +0| foo.bar(int aaa, int bbb); + +[Domain] = 0:0-0:25 + >-------------------------< +0| foo.bar(int aaa, int bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argument.actual.constructor.iteration.scope b/data/fixtures/scopes/cpp/argument.actual.constructor.iteration.scope new file mode 100644 index 0000000000..13be0a78c1 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.actual.constructor.iteration.scope @@ -0,0 +1,10 @@ +new Foo(aaa, bbb); +--- + +[Range] = 0:8-0:16 + >--------< +0| new Foo(aaa, bbb); + +[Domain] = 0:0-0:17 + >-----------------< +0| new Foo(aaa, bbb); diff --git a/data/fixtures/scopes/cpp/argument.actual.constructor.scope b/data/fixtures/scopes/cpp/argument.actual.constructor.scope new file mode 100644 index 0000000000..afee36448c --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.actual.constructor.scope @@ -0,0 +1,33 @@ +new Foo(aaa, bbb); +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:11 + >---< +0| new Foo(aaa, bbb); + +[#1 Removal] = 0:8-0:13 + >-----< +0| new Foo(aaa, bbb); + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| new Foo(aaa, bbb); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| new Foo(aaa, bbb); + +[#2 Removal] = 0:11-0:16 + >-----< +0| new Foo(aaa, bbb); + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| new Foo(aaa, bbb); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/cpp/argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..fbe34ad648 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.constructor.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + Foo(int aaa, int bbb) {} +} +--- + +[Range] = 1:8-1:24 + >----------------< +1| Foo(int aaa, int bbb) {} + +[Domain] = 1:4-1:28 + >------------------------< +1| Foo(int aaa, int bbb) {} diff --git a/data/fixtures/scopes/cpp/argument.formal.constructor.scope b/data/fixtures/scopes/cpp/argument.formal.constructor.scope new file mode 100644 index 0000000000..18092d00a8 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.constructor.scope @@ -0,0 +1,35 @@ +class Foo { + Foo(int aaa, int bbb) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:15 + >-------< +1| Foo(int aaa, int bbb) {} + +[#1 Removal] = 1:8-1:17 + >---------< +1| Foo(int aaa, int bbb) {} + +[#1 Trailing delimiter] = 1:15-1:17 + >--< +1| Foo(int aaa, int bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:17-1:24 + >-------< +1| Foo(int aaa, int bbb) {} + +[#2 Removal] = 1:15-1:24 + >---------< +1| Foo(int aaa, int bbb) {} + +[#2 Leading delimiter] = 1:15-1:17 + >--< +1| Foo(int aaa, int bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/cpp/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..2aca516e66 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +[](int aaa, int bbb) {} +--- + +[Range] = 0:3-0:19 + >----------------< +0| [](int aaa, int bbb) {} + +[Domain] = 0:0-0:23 + >-----------------------< +0| [](int aaa, int bbb) {} diff --git a/data/fixtures/scopes/cpp/argument.formal.lambda.scope b/data/fixtures/scopes/cpp/argument.formal.lambda.scope new file mode 100644 index 0000000000..d5e70e698c --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.lambda.scope @@ -0,0 +1,33 @@ +[](int aaa, int bbb) {} +--- + +[#1 Content] = +[#1 Domain] = 0:3-0:10 + >-------< +0| [](int aaa, int bbb) {} + +[#1 Removal] = 0:3-0:12 + >---------< +0| [](int aaa, int bbb) {} + +[#1 Trailing delimiter] = 0:10-0:12 + >--< +0| [](int aaa, int bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:12-0:19 + >-------< +0| [](int aaa, int bbb) {} + +[#2 Removal] = 0:10-0:19 + >---------< +0| [](int aaa, int bbb) {} + +[#2 Leading delimiter] = 0:10-0:12 + >--< +0| [](int aaa, int bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argument.formal.method.iteration.scope b/data/fixtures/scopes/cpp/argument.formal.method.iteration.scope new file mode 100644 index 0000000000..7ce9ad3e21 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.method.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + void bar(int aaa, int bbb) {} +} +--- + +[Range] = 1:13-1:29 + >----------------< +1| void bar(int aaa, int bbb) {} + +[Domain] = 1:4-1:33 + >-----------------------------< +1| void bar(int aaa, int bbb) {} diff --git a/data/fixtures/scopes/cpp/argument.formal.method.scope b/data/fixtures/scopes/cpp/argument.formal.method.scope new file mode 100644 index 0000000000..475653f2d6 --- /dev/null +++ b/data/fixtures/scopes/cpp/argument.formal.method.scope @@ -0,0 +1,35 @@ +class Foo { + void bar(int aaa, int bbb) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:13-1:20 + >-------< +1| void bar(int aaa, int bbb) {} + +[#1 Removal] = 1:13-1:22 + >---------< +1| void bar(int aaa, int bbb) {} + +[#1 Trailing delimiter] = 1:20-1:22 + >--< +1| void bar(int aaa, int bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:22-1:29 + >-------< +1| void bar(int aaa, int bbb) {} + +[#2 Removal] = 1:20-1:29 + >---------< +1| void bar(int aaa, int bbb) {} + +[#2 Leading delimiter] = 1:20-1:22 + >--< +1| void bar(int aaa, int bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argumentList.actual.constructor.empty.scope b/data/fixtures/scopes/cpp/argumentList.actual.constructor.empty.scope new file mode 100644 index 0000000000..728f90d07c --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.actual.constructor.empty.scope @@ -0,0 +1,13 @@ +new Foo(); +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| new Foo(); + +[Domain] = 0:0-0:9 + >---------< +0| new Foo(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/cpp/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/cpp/argumentList.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..b2310d5500 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.actual.constructor.multiLine.scope @@ -0,0 +1,24 @@ +new Foo( + int aaa, + int bbb +); +--- + +[Content] = +[Removal] = 0:8-3:0 + > +0| new Foo( +1| int aaa, +2| int bbb +3| ); + < + +[Domain] = 0:0-3:1 + >-------- +0| new Foo( +1| int aaa, +2| int bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/cpp/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/cpp/argumentList.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..0b741fe1b9 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.actual.constructor.singleLine.scope @@ -0,0 +1,13 @@ +new Foo(int aaa, int bbb); +--- + +[Content] = +[Removal] = 0:8-0:24 + >----------------< +0| new Foo(int aaa, int bbb); + +[Domain] = 0:0-0:25 + >-------------------------< +0| new Foo(int aaa, int bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argumentList.formal.constructor.empty.scope b/data/fixtures/scopes/cpp/argumentList.formal.constructor.empty.scope new file mode 100644 index 0000000000..c7f415a0c5 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.constructor.empty.scope @@ -0,0 +1,15 @@ +class MyClass { + MyClass() {} +} +--- + +[Content] = +[Removal] = 1:12-1:12 + >< +1| MyClass() {} + +[Domain] = 1:4-1:16 + >------------< +1| MyClass() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.constructor.multiLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..f6f61f1d52 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.constructor.multiLine.scope @@ -0,0 +1,26 @@ +class MyClass { + MyClass( + int aaa, + int bbb + ) {} +} +--- + +[Content] = +[Removal] = 1:12-4:4 + > +1| MyClass( +2| int aaa, +3| int bbb +4| ) {} + ----< + +[Domain] = 1:4-4:8 + >-------- +1| MyClass( +2| int aaa, +3| int bbb +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.constructor.singleLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..ba318a7b14 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.constructor.singleLine.scope @@ -0,0 +1,15 @@ +class MyClass { + MyClass(int aaa, int bbb) {} +} +--- + +[Content] = +[Removal] = 1:12-1:28 + >----------------< +1| MyClass(int aaa, int bbb) {} + +[Domain] = 1:4-1:32 + >----------------------------< +1| MyClass(int aaa, int bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/cpp/argumentList.formal.lambda.empty.scope new file mode 100644 index 0000000000..f7e9e835c7 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.lambda.empty.scope @@ -0,0 +1,13 @@ +[]() {} +--- + +[Content] = +[Removal] = 0:3-0:3 + >< +0| []() {} + +[Domain] = 0:0-0:7 + >-------< +0| []() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..38ec6cb1eb --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.lambda.multiLine.scope @@ -0,0 +1,24 @@ +[]( + int aaa, + int bbb +) {} +--- + +[Content] = +[Removal] = 0:3-3:0 + > +0| []( +1| int aaa, +2| int bbb +3| ) {} + < + +[Domain] = 0:0-3:4 + >--- +0| []( +1| int aaa, +2| int bbb +3| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..5c7166c878 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.lambda.singleLine.scope @@ -0,0 +1,13 @@ +[](int aaa, int bbb) {} +--- + +[Content] = +[Removal] = 0:3-0:19 + >----------------< +0| [](int aaa, int bbb) {} + +[Domain] = 0:0-0:23 + >-----------------------< +0| [](int aaa, int bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/argumentList.formal.method.empty.scope b/data/fixtures/scopes/cpp/argumentList.formal.method.empty.scope new file mode 100644 index 0000000000..47572da9e3 --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.method.empty.scope @@ -0,0 +1,15 @@ +class MyClass { + void foo() {} +} +--- + +[Content] = +[Removal] = 1:13-1:13 + >< +1| void foo() {} + +[Domain] = 1:4-1:17 + >-------------< +1| void foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.method.multiLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.method.multiLine.scope new file mode 100644 index 0000000000..f4d2f4ebcf --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.method.multiLine.scope @@ -0,0 +1,26 @@ +class MyClass { + void foo( + int aaa, + int bbb + ) {} +} +--- + +[Content] = +[Removal] = 1:13-4:4 + > +1| void foo( +2| int aaa, +3| int bbb +4| ) {} + ----< + +[Domain] = 1:4-4:8 + >--------- +1| void foo( +2| int aaa, +3| int bbb +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/cpp/argumentList.formal.method.singleLine.scope b/data/fixtures/scopes/cpp/argumentList.formal.method.singleLine.scope new file mode 100644 index 0000000000..35af67a9ce --- /dev/null +++ b/data/fixtures/scopes/cpp/argumentList.formal.method.singleLine.scope @@ -0,0 +1,15 @@ +class MyClass { + void foo(int aaa, int bbb) {} +} +--- + +[Content] = +[Removal] = 1:13-1:29 + >----------------< +1| void foo(int aaa, int bbb) {} + +[Domain] = 1:4-1:33 + >-----------------------------< +1| void foo(int aaa, int bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/name.constructor.scope b/data/fixtures/scopes/cpp/name.constructor.scope new file mode 100644 index 0000000000..62614526f6 --- /dev/null +++ b/data/fixtures/scopes/cpp/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/cpp/name.constructor2.scope b/data/fixtures/scopes/cpp/name.constructor2.scope new file mode 100644 index 0000000000..151755da1b --- /dev/null +++ b/data/fixtures/scopes/cpp/name.constructor2.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:12 + >--------< +1| ~MyClass() {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| ~MyClass() {} + +[#2 Domain] = 1:4-1:17 + >-------------< +1| ~MyClass() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/name.method.scope b/data/fixtures/scopes/cpp/name.method.scope new file mode 100644 index 0000000000..f90b15c7de --- /dev/null +++ b/data/fixtures/scopes/cpp/name.method.scope @@ -0,0 +1,45 @@ +class MyClass { + void 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 foo() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:12 + >---< +1| void foo() {} + +[#2 Leading delimiter] = 1:8-1:9 + >-< +1| void foo() {} + +[#2 Domain] = 1:4-1:17 + >-------------< +1| void foo() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/switchStatementSubject.scope b/data/fixtures/scopes/cpp/switchStatementSubject.scope new file mode 100644 index 0000000000..6cc122d5a9 --- /dev/null +++ b/data/fixtures/scopes/cpp/switchStatementSubject.scope @@ -0,0 +1,13 @@ +switch (int i = rand() % 100; i) {} +--- + +[Content] = +[Removal] = 0:8-0:31 + >-----------------------< +0| switch (int i = rand() % 100; i) {} + +[Domain] = 0:0-0:35 + >-----------------------------------< +0| switch (int i = rand() % 100; i) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/cpp/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..d6b31aea6c --- /dev/null +++ b/data/fixtures/scopes/cpp/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,18 @@ +class MyClass { + MyClass(int aaa, int bbb) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| MyClass(int aaa, int bbb) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:12-1:28 + >----------------< +1| MyClass(int aaa, int bbb) {} diff --git a/data/fixtures/scopes/cpp/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/cpp/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..1c4875f65e --- /dev/null +++ b/data/fixtures/scopes/cpp/type.argument.formal.method.iteration.scope @@ -0,0 +1,18 @@ +class MyClass { + void foo(int aaa, int bbb) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| void foo(int aaa, int bbb) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:13-1:29 + >----------------< +1| void foo(int aaa, int bbb) {} diff --git a/data/fixtures/scopes/cpp/value.return.lambda.scope b/data/fixtures/scopes/cpp/value.return.lambda.scope new file mode 100644 index 0000000000..a7a8d0d82c --- /dev/null +++ b/data/fixtures/scopes/cpp/value.return.lambda.scope @@ -0,0 +1,22 @@ +[]() { + return 0; +} +--- + +[Content] = 1:11-1:12 + >-< +1| return 0; + +[Removal] = 1:10-1:12 + >--< +1| return 0; + +[Leading delimiter] = 1:10-1:11 + >-< +1| return 0; + +[Domain] = 1:4-1:13 + >---------< +1| return 0; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index 921f04d24e..7258bbd57e 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -40,6 +40,9 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.actual.empty": supported, "argumentList.actual.singleLine": supported, "argumentList.actual.multiLine": supported, + "argumentList.actual.method.empty": supported, + "argumentList.actual.method.singleLine": supported, + "argumentList.actual.method.multiLine": supported, "argumentList.formal.empty": supported, "argumentList.formal.singleLine": supported, "argumentList.formal.multiLine": supported, @@ -163,6 +166,10 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "class.iteration.block": notApplicable, "className.iteration.block": notApplicable, + // Nested function + "functionName.iteration.block": notApplicable, + "namedFunction.iteration.block": notApplicable, + // Try catch "branch.try": notApplicable, "branch.try.iteration": notApplicable, @@ -224,9 +231,6 @@ export const cScopeSupport: LanguageScopeSupportFacetMap = { // Method "argument.formal.method.iteration": notApplicable, "argument.formal.method": notApplicable, - "argumentList.actual.method.empty": notApplicable, - "argumentList.actual.method.multiLine": notApplicable, - "argumentList.actual.method.singleLine": notApplicable, "argumentList.formal.method.empty": notApplicable, "argumentList.formal.method.multiLine": notApplicable, "argumentList.formal.method.singleLine": notApplicable, @@ -254,8 +258,4 @@ export const cScopeSupport: LanguageScopeSupportFacetMap = { // Generic type "type.typeArgument": notApplicable, "type.typeArgument.iteration": notApplicable, - - // Nested function - "functionName.iteration.block": notApplicable, - "namedFunction.iteration.block": notApplicable, }; diff --git a/packages/common/src/scopeSupportFacets/cpp.ts b/packages/common/src/scopeSupportFacets/cpp.ts index 48734ba21e..ba612187e9 100644 --- a/packages/common/src/scopeSupportFacets/cpp.ts +++ b/packages/common/src/scopeSupportFacets/cpp.ts @@ -7,14 +7,52 @@ const { supported, unsupported } = ScopeSupportFacetLevel; export const cppScopeSupport: LanguageScopeSupportFacetMap = { ...cCoreScopeSupport, + attribute: supported, + anonymousFunction: supported, + + "branch.try": supported, + "branch.try.iteration": supported, + + "argument.actual.constructor": supported, + "argument.actual.constructor.iteration": supported, + "argument.formal.method": supported, + "argument.formal.method.iteration": supported, + "argument.formal.constructor": supported, + "argument.formal.constructor.iteration": supported, + "argument.formal.lambda": supported, + "argument.formal.lambda.iteration": supported, + + "argumentList.actual.constructor.empty": supported, + "argumentList.actual.constructor.singleLine": supported, + "argumentList.actual.constructor.multiLine": supported, + "argumentList.formal.constructor.empty": supported, + "argumentList.formal.constructor.singleLine": supported, + "argumentList.formal.constructor.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, + "argumentList.formal.method.empty": supported, + "argumentList.formal.method.singleLine": supported, + "argumentList.formal.method.multiLine": supported, + + "functionCall.constructor": supported, + "functionCallee.constructor": supported, + "functionName.constructor": supported, "functionName.method": supported, + "functionName.method.iteration.class": supported, "namedFunction.method": supported, + "namedFunction.method.iteration.class": supported, "namedFunction.constructor": supported, - attribute: supported, - anonymousFunction: supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, + "name.constructor": supported, + "name.foreach": supported, + "name.method": supported, "value.argument.formal": supported, "value.argument.formal.iteration": supported, @@ -22,67 +60,20 @@ export const cppScopeSupport: LanguageScopeSupportFacetMap = { "value.argument.formal.method.iteration": supported, "value.argument.formal.constructor": supported, "value.argument.formal.constructor.iteration": supported, - - "name.argument.formal.method": supported, - "name.argument.formal.method.iteration": supported, - "name.argument.formal.constructor": supported, - "name.argument.formal.constructor.iteration": supported, + "value.foreach": supported, + "value.return.lambda": supported, + "value.field": supported, "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, "type.foreach": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, // Unsupported - "argument.actual.constructor": unsupported, - "argument.actual.constructor.iteration": unsupported, - "argument.formal.method": unsupported, - "argument.formal.method.iteration": unsupported, - "argument.formal.constructor": unsupported, - "argument.formal.constructor.iteration": unsupported, - "argument.formal.lambda": unsupported, - "argument.formal.lambda.iteration": unsupported, - - "argumentList.actual.method.empty": unsupported, - "argumentList.actual.method.singleLine": unsupported, - "argumentList.actual.method.multiLine": unsupported, - "argumentList.actual.constructor.empty": unsupported, - "argumentList.actual.constructor.singleLine": unsupported, - "argumentList.actual.constructor.multiLine": unsupported, - "argumentList.formal.constructor.empty": unsupported, - "argumentList.formal.constructor.singleLine": unsupported, - "argumentList.formal.constructor.multiLine": unsupported, - "argumentList.formal.lambda.empty": unsupported, - "argumentList.formal.lambda.singleLine": unsupported, - "argumentList.formal.lambda.multiLine": unsupported, - "argumentList.formal.method.empty": unsupported, - "argumentList.formal.method.singleLine": unsupported, - "argumentList.formal.method.multiLine": unsupported, - - "functionName.iteration.block": unsupported, - "functionName.method.iteration.class": unsupported, - - "functionCall.constructor": unsupported, - "functionCallee.constructor": unsupported, - - "name.constructor": unsupported, - "name.foreach": unsupported, - "name.method": unsupported, - "namedFunction.iteration.block": unsupported, - "namedFunction.method.iteration.class": unsupported, - - "value.foreach": unsupported, - "value.return.lambda": unsupported, - "value.field": unsupported, - - "type.typeArgument": unsupported, - "type.typeArgument.iteration": unsupported, - "type.argument.formal.method.iteration": unsupported, - "type.argument.formal.constructor.iteration": unsupported, - "interior.lambda": unsupported, - - "branch.try": unsupported, - "branch.try.iteration": unsupported, "interior.try": unsupported, }; diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index 50f8d452ef..3cbdcc53eb 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -111,7 +111,7 @@ export const scopeSupportFacetInfos: Record< }, "class.iteration.block": { description: - "Iteration scope for classes. Statement blocks(body of functions/if classes/for loops/etc).", + "Iteration scope for classes. Statement blocks(body of functions/if statements/for loops/etc).", scopeType: "class", isIteration: true, }, @@ -126,7 +126,7 @@ export const scopeSupportFacetInfos: Record< }, "className.iteration.block": { description: - "Iteration scope for class names. Statement blocks(body of functions/if classes/for loops/etc).", + "Iteration scope for class names. Statement blocks(body of functions/if statements/for loops/etc).", scopeType: "className", isIteration: true, }, @@ -150,7 +150,7 @@ export const scopeSupportFacetInfos: Record< }, "namedFunction.iteration.block": { description: - "Iteration scope for named functions. Statement blocks(body of functions/if classes/for loops/etc).", + "Iteration scope for named functions. Statement blocks(body of functions/if statements/for loops/etc).", scopeType: "namedFunction", isIteration: true, }, @@ -183,7 +183,7 @@ export const scopeSupportFacetInfos: Record< }, "functionName.iteration.block": { description: - "Iteration scope for function names. Statement blocks(body of functions/if classes/for loops/etc).", + "Iteration scope for function names. Statement blocks(body of functions/if statements/for loops/etc).", scopeType: "functionName", isIteration: true, }, @@ -618,7 +618,7 @@ export const scopeSupportFacetInfos: Record< }, "name.iteration.block": { description: - "Iteration scope for names: statement blocks (body of functions/if classes/for loops/etc).", + "Iteration scope for names: statement blocks (body of functions/if statements/for loops/etc).", scopeType: "name", isIteration: true, }, diff --git a/queries/c.scm b/queries/c.scm index 46a4b8856b..46c06f6b3d 100644 --- a/queries/c.scm +++ b/queries/c.scm @@ -258,7 +258,7 @@ ;;!! void foo(int aaa, int bbb) {} ;;! ^^^^^^^^^^^^^^^^ (_ - (function_declarator + declarator: (_ (parameter_list "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf diff --git a/queries/cpp.scm b/queries/cpp.scm index 6cecaf55be..e5d4b72ea9 100644 --- a/queries/cpp.scm +++ b/queries/cpp.scm @@ -42,6 +42,8 @@ ) ) @_.domain +;;!! []() {} +;;! ^^^^^^^ (lambda_expression) @anonymousFunction ;;!! [[attribute]] From 121e99cd27639b8ac486a99e5d06418403789d5b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 8 Jun 2025 12:44:09 +0200 Subject: [PATCH 2/2] Added missing scope implementations --- .../scopes/cpp/branch.try.iteration.scope | 10 ++++ data/fixtures/scopes/cpp/branch.try.scope | 30 ++++++++++ .../scopes/cpp/functionCall.constructor.scope | 10 ++++ .../cpp/functionCallee.constructor.scope | 13 ++++ .../functionName.method.iteration.class.scope | 13 ++++ ...rgument.formal.constructor.iteration.scope | 15 ++++- ...ame.argument.formal.method.iteration.scope | 15 ++++- data/fixtures/scopes/cpp/name.field.scope | 49 ++++++++------- data/fixtures/scopes/cpp/name.foreach.scope | 24 ++++++++ ...namedFunction.method.iteration.class.scope | 13 ++++ data/fixtures/scopes/cpp/type.field.scope | 43 +++++++------ .../cpp/type.typeArgument.iteration.scope | 7 +++ .../scopes/cpp/type.typeArgument.scope | 52 ++++++++++++++++ ...rgument.formal.constructor.iteration.scope | 13 +++- ...lue.argument.formal.method.iteration.scope | 13 +++- data/fixtures/scopes/cpp/value.field.scope | 22 +++++++ data/fixtures/scopes/cpp/value.foreach.scope | 20 +++++++ queries/c.scm | 20 ++++--- queries/cpp.scm | 60 ++++++++++++++++++- 19 files changed, 385 insertions(+), 57 deletions(-) create mode 100644 data/fixtures/scopes/cpp/branch.try.iteration.scope create mode 100644 data/fixtures/scopes/cpp/branch.try.scope create mode 100644 data/fixtures/scopes/cpp/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/cpp/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/cpp/functionName.method.iteration.class.scope create mode 100644 data/fixtures/scopes/cpp/name.foreach.scope create mode 100644 data/fixtures/scopes/cpp/namedFunction.method.iteration.class.scope create mode 100644 data/fixtures/scopes/cpp/type.typeArgument.iteration.scope create mode 100644 data/fixtures/scopes/cpp/type.typeArgument.scope create mode 100644 data/fixtures/scopes/cpp/value.field.scope create mode 100644 data/fixtures/scopes/cpp/value.foreach.scope diff --git a/data/fixtures/scopes/cpp/branch.try.iteration.scope b/data/fixtures/scopes/cpp/branch.try.iteration.scope new file mode 100644 index 0000000000..a21e00f9c0 --- /dev/null +++ b/data/fixtures/scopes/cpp/branch.try.iteration.scope @@ -0,0 +1,10 @@ +try {} +catch (const std::exception& e) {} +--- + +[Range] = +[Domain] = 0:0-1:34 + >------ +0| try {} +1| catch (const std::exception& e) {} + ----------------------------------< diff --git a/data/fixtures/scopes/cpp/branch.try.scope b/data/fixtures/scopes/cpp/branch.try.scope new file mode 100644 index 0000000000..d34a05b27e --- /dev/null +++ b/data/fixtures/scopes/cpp/branch.try.scope @@ -0,0 +1,30 @@ +try {} +catch (const std::exception& e) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:6 + >------< +0| try {} + +[#1 Removal] = 0:0-1:0 + >------ +0| try {} +1| catch (const std::exception& e) {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:34 + >----------------------------------< +1| catch (const std::exception& e) {} + +[#2 Removal] = 0:6-1:34 + > +0| try {} +1| catch (const std::exception& e) {} + ----------------------------------< + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/cpp/functionCall.constructor.scope b/data/fixtures/scopes/cpp/functionCall.constructor.scope new file mode 100644 index 0000000000..d94f8bf315 --- /dev/null +++ b/data/fixtures/scopes/cpp/functionCall.constructor.scope @@ -0,0 +1,10 @@ +new Foo(); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| new Foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/functionCallee.constructor.scope b/data/fixtures/scopes/cpp/functionCallee.constructor.scope new file mode 100644 index 0000000000..81ac744168 --- /dev/null +++ b/data/fixtures/scopes/cpp/functionCallee.constructor.scope @@ -0,0 +1,13 @@ +new Foo(); +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| new Foo(); + +[Domain] = 0:0-0:9 + >---------< +0| new Foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/functionName.method.iteration.class.scope b/data/fixtures/scopes/cpp/functionName.method.iteration.class.scope new file mode 100644 index 0000000000..a9bd7ec26f --- /dev/null +++ b/data/fixtures/scopes/cpp/functionName.method.iteration.class.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/cpp/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope index 68f7d20468..64ed1e42bd 100644 --- a/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope @@ -13,12 +13,21 @@ class MyClass { [#2 Range] = -[#2 Domain] = 1:12-1:32 - >--------------------< +[#2 Domain] = 0:15-2:0 + > +0| class MyClass { 1| MyClass(int aaa, int bbb = 2) {} +2| } + < [#3 Range] = -[#3 Domain] = 1:35-1:35 +[#3 Domain] = 1:12-1:32 + >--------------------< +1| MyClass(int aaa, int bbb = 2) {} + + +[#4 Range] = +[#4 Domain] = 1:35-1:35 >< 1| MyClass(int aaa, int bbb = 2) {} diff --git a/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope index ad30506e8a..9b6a131190 100644 --- a/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope @@ -13,12 +13,21 @@ class MyClass { [#2 Range] = -[#2 Domain] = 1:13-1:33 - >--------------------< +[#2 Domain] = 0:15-2:0 + > +0| class MyClass { 1| void foo(int aaa, int bbb = 2) {} +2| } + < [#3 Range] = -[#3 Domain] = 1:36-1:36 +[#3 Domain] = 1:13-1:33 + >--------------------< +1| void foo(int aaa, int bbb = 2) {} + + +[#4 Range] = +[#4 Domain] = 1:36-1:36 >< 1| void foo(int aaa, int bbb = 2) {} diff --git a/data/fixtures/scopes/cpp/name.field.scope b/data/fixtures/scopes/cpp/name.field.scope index ae8cd268cf..ffc1fc0f7e 100644 --- a/data/fixtures/scopes/cpp/name.field.scope +++ b/data/fixtures/scopes/cpp/name.field.scope @@ -1,43 +1,52 @@ -class aaa { int bbb; }; +class Foo { + int aaa = 2; +} --- [#1 Content] = 0:6-0:9 >---< -0| class aaa { int bbb; }; +0| class Foo { [#1 Removal] = 0:6-0:10 >----< -0| class aaa { int bbb; }; +0| class Foo { [#1 Leading delimiter] = 0:5-0:6 >-< -0| class aaa { int bbb; }; +0| class Foo { [#1 Trailing delimiter] = 0:9-0:10 >-< -0| class aaa { int bbb; }; +0| class Foo { -[#1 Domain] = 0:0-0:23 - >-----------------------< -0| class aaa { int bbb; }; +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| int aaa = 2; +2| } + -< [#1 Insertion delimiter] = " " -[#2 Content] = 0:16-0:19 - >---< -0| class aaa { int bbb; }; +[#2 Content] = 1:8-1:11 + >---< +1| int aaa = 2; -[#2 Removal] = 0:15-0:19 - >----< -0| class aaa { int bbb; }; +[#2 Removal] = 1:8-1:12 + >----< +1| int aaa = 2; -[#2 Leading delimiter] = 0:15-0:16 - >-< -0| class aaa { int bbb; }; +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| int aaa = 2; -[#2 Domain] = 0:12-0:20 - >--------< -0| class aaa { int bbb; }; +[#2 Trailing delimiter] = 1:11-1:12 + >-< +1| int aaa = 2; + +[#2 Domain] = 1:4-1:16 + >------------< +1| int aaa = 2; [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/name.foreach.scope b/data/fixtures/scopes/cpp/name.foreach.scope new file mode 100644 index 0000000000..0ecd1b2047 --- /dev/null +++ b/data/fixtures/scopes/cpp/name.foreach.scope @@ -0,0 +1,24 @@ +for (int value : values) {} +--- + +[Content] = 0:9-0:14 + >-----< +0| for (int value : values) {} + +[Removal] = 0:9-0:15 + >------< +0| for (int value : values) {} + +[Leading delimiter] = 0:8-0:9 + >-< +0| for (int value : values) {} + +[Trailing delimiter] = 0:14-0:15 + >-< +0| for (int value : values) {} + +[Domain] = 0:0-0:27 + >---------------------------< +0| for (int value : values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/namedFunction.method.iteration.class.scope b/data/fixtures/scopes/cpp/namedFunction.method.iteration.class.scope new file mode 100644 index 0000000000..a9bd7ec26f --- /dev/null +++ b/data/fixtures/scopes/cpp/namedFunction.method.iteration.class.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/cpp/type.field.scope b/data/fixtures/scopes/cpp/type.field.scope index 1924254048..69c762d264 100644 --- a/data/fixtures/scopes/cpp/type.field.scope +++ b/data/fixtures/scopes/cpp/type.field.scope @@ -1,33 +1,38 @@ -class aaa { int bbb; }; +class Foo { + int aaa = 2; +} --- [#1 Content] = [#1 Removal] = -[#1 Domain] = 0:0-0:23 - >-----------------------< -0| class aaa { int bbb; }; +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| int aaa = 2; +2| } + -< [#1 Insertion delimiter] = " " -[#2 Content] = 0:12-0:15 - >---< -0| class aaa { int bbb; }; +[#2 Content] = 1:4-1:7 + >---< +1| int aaa = 2; -[#2 Removal] = 0:12-0:16 - >----< -0| class aaa { int bbb; }; +[#2 Removal] = 1:4-1:8 + >----< +1| int aaa = 2; -[#2 Leading delimiter] = 0:11-0:12 - >-< -0| class aaa { int bbb; }; +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int aaa = 2; -[#2 Trailing delimiter] = 0:15-0:16 - >-< -0| class aaa { int bbb; }; +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int aaa = 2; -[#2 Domain] = 0:12-0:20 - >--------< -0| class aaa { int bbb; }; +[#2 Domain] = 1:4-1:16 + >------------< +1| int aaa = 2; [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/type.typeArgument.iteration.scope b/data/fixtures/scopes/cpp/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..fde8c6354e --- /dev/null +++ b/data/fixtures/scopes/cpp/type.typeArgument.iteration.scope @@ -0,0 +1,7 @@ +Map foo; +--- + +[Range] = +[Domain] = 0:4-0:15 + >-----------< +0| Map foo; diff --git a/data/fixtures/scopes/cpp/type.typeArgument.scope b/data/fixtures/scopes/cpp/type.typeArgument.scope new file mode 100644 index 0000000000..4a9bc0d8fd --- /dev/null +++ b/data/fixtures/scopes/cpp/type.typeArgument.scope @@ -0,0 +1,52 @@ +Map foo; +--- + +[#1 Content] = 0:0-0:16 + >----------------< +0| Map foo; + +[#1 Removal] = 0:0-0:17 + >-----------------< +0| Map foo; + +[#1 Trailing delimiter] = 0:16-0:17 + >-< +0| Map foo; + +[#1 Domain] = 0:0-0:21 + >---------------------< +0| Map foo; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:4-0:10 + >------< +0| Map foo; + +[#2 Removal] = 0:4-0:12 + >--------< +0| Map foo; + +[#2 Trailing delimiter] = 0:10-0:12 + >--< +0| Map foo; + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:12-0:15 + >---< +0| Map foo; + +[#3 Removal] = 0:10-0:15 + >-----< +0| Map foo; + +[#3 Leading delimiter] = 0:10-0:12 + >--< +0| Map foo; + +[#3 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/cpp/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/cpp/value.argument.formal.constructor.iteration.scope index d75a3ce2e3..48cc8810d5 100644 --- a/data/fixtures/scopes/cpp/value.argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/cpp/value.argument.formal.constructor.iteration.scope @@ -3,7 +3,16 @@ class MyClass { } --- -[Range] = -[Domain] = 1:12-1:32 +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| MyClass(int aaa, int bbb = 2) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:12-1:32 >--------------------< 1| MyClass(int aaa, int bbb = 2) {} diff --git a/data/fixtures/scopes/cpp/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/cpp/value.argument.formal.method.iteration.scope index ee053b4452..d6a6f3aaba 100644 --- a/data/fixtures/scopes/cpp/value.argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/cpp/value.argument.formal.method.iteration.scope @@ -3,7 +3,16 @@ class MyClass { } --- -[Range] = -[Domain] = 1:13-1:33 +[#1 Range] = +[#1 Domain] = 0:15-2:0 + > +0| class MyClass { +1| void foo(int aaa, int bbb = 2) {} +2| } + < + + +[#2 Range] = +[#2 Domain] = 1:13-1:33 >--------------------< 1| void foo(int aaa, int bbb = 2) {} diff --git a/data/fixtures/scopes/cpp/value.field.scope b/data/fixtures/scopes/cpp/value.field.scope new file mode 100644 index 0000000000..feff9f2520 --- /dev/null +++ b/data/fixtures/scopes/cpp/value.field.scope @@ -0,0 +1,22 @@ +class Foo { + int aaa = 2; +} +--- + +[Content] = 1:14-1:15 + >-< +1| int aaa = 2; + +[Removal] = 1:11-1:15 + >----< +1| int aaa = 2; + +[Leading delimiter] = 1:11-1:14 + >---< +1| int aaa = 2; + +[Domain] = 1:4-1:16 + >------------< +1| int aaa = 2; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/cpp/value.foreach.scope b/data/fixtures/scopes/cpp/value.foreach.scope new file mode 100644 index 0000000000..fdfdae58f1 --- /dev/null +++ b/data/fixtures/scopes/cpp/value.foreach.scope @@ -0,0 +1,20 @@ +for (int value : values) {} +--- + +[Content] = 0:17-0:23 + >------< +0| for (int value : values) {} + +[Removal] = 0:16-0:23 + >-------< +0| for (int value : values) {} + +[Leading delimiter] = 0:16-0:17 + >-< +0| for (int value : values) {} + +[Domain] = 0:0-0:27 + >---------------------------< +0| for (int value : values) {} + +[Insertion delimiter] = " " diff --git a/queries/c.scm b/queries/c.scm index 46c06f6b3d..5000ae8a22 100644 --- a/queries/c.scm +++ b/queries/c.scm @@ -41,8 +41,8 @@ ) (field_declaration_list - "{" @type.iteration.start.endOf - "}" @type.iteration.end.startOf + "{" @type.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf + "}" @type.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf ) ;; Body of statements @@ -114,12 +114,14 @@ ) declarator: (type_identifier) @className @name ) @_.domain @class @type + (type_definition type: (enum_specifier body: (_) ) declarator: (type_identifier) @className @name ) @_.domain @class @type + (type_definition type: (union_specifier body: (_) @@ -162,24 +164,28 @@ ) ) @namedFunction @functionName.domain @name.domain +;;!! int aaa; +;;! ^^^ (field_declaration declarator: (_ !declarator ) @name -) @name.domain +) @_.domain + (field_declaration declarator: (_ declarator: (_) @name ) -) @name.domain +) @_.domain (initializer_list) @list -(call_expression) @functionCall - +;;!! foo() +;;! ^^^^^ +;;! ^^^ (call_expression function: (_) @functionCallee -) @_.domain +) @functionCall @functionCallee.domain ;;!! int aaa = 0; (declaration diff --git a/queries/cpp.scm b/queries/cpp.scm index e5d4b72ea9..ab2408f4c9 100644 --- a/queries/cpp.scm +++ b/queries/cpp.scm @@ -24,6 +24,7 @@ . ";"? @_.domain.end @class.end @type.end ) + (_ (class_specifier name: (_) @@ -33,6 +34,18 @@ ";"? @statement.end ) +(field_declaration_list + "{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf + "}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf +) @_.domain + +;;!! int aaa = 0; +;;! ^ +(field_declaration + declarator: (_) @_.leading.endOf + default_value: (_) @value +) @_.domain + ;;!! void ClassName::method() {} (function_definition declarator: (_ @@ -54,7 +67,6 @@ (auto) (decltype) (dependent_type) - (template_type) ] @type ;;!! void foo(int value = 0) {} @@ -72,6 +84,52 @@ ) @functionCall.end @_.domain.end ) +;;!! try {} +;;! ^^^^^^ +(try_statement + "try" @branch.start + body: (_) @branch.end +) @branch.iteration + +;;!! catch (const std::exception& e) {} +(catch_clause) @branch + +;;!! new Foo() +;;! ^^^^^^^^^ +;;! ^^^^^^^ +(new_expression + "new" @functionCallee.start + type: (_) @functionCallee.end +) @functionCall @functionCallee.domain + +;;!! Map foo; +;;! ^^^^^^ ^^^ +( + (template_argument_list + (_)? @_.leading.endOf + . + (type_descriptor) @type + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @type @_dummy ", " ",\n") +) + +;;!! Map foo; +;;! ^^^^^^^^^^^ +(template_argument_list + "<" @type.iteration.start.endOf + ">" @type.iteration.end.startOf +) + +;;!! for (int value : values) {} +;;! ^^^^^ +;;! ^^^^^^ +(for_range_loop + declarator: (_) @name + right: (_) @value +) @_.domain + (trailing_return_type "->" @disqualifyDelimiter )