diff --git a/data/fixtures/recorded/languages/cpp/clearSubject2.yml b/data/fixtures/recorded/languages/cpp/clearSubject2.yml index e9a6dc20eb..0da97e7df2 100644 --- a/data/fixtures/recorded/languages/cpp/clearSubject2.yml +++ b/data/fixtures/recorded/languages/cpp/clearSubject2.yml @@ -28,11 +28,11 @@ initialState: finalState: documentContents: | int main() { - switch (int i = rand() % 100; ) { + switch () { default: break; } } selections: - - anchor: {line: 1, character: 32} - active: {line: 1, character: 32} + - anchor: {line: 1, character: 10} + active: {line: 1, character: 10} diff --git a/data/fixtures/scopes/c/argumentList.actual.empty.scope b/data/fixtures/scopes/c/argumentList.actual.empty.scope new file mode 100644 index 0000000000..539138bcb6 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.empty.scope @@ -0,0 +1,13 @@ +foo(); +--- + +[Content] = +[Removal] = 0:4-0:4 + >< +0| foo(); + +[Domain] = 0:0-0:5 + >-----< +0| foo(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/c/argumentList.actual.multiLine.scope b/data/fixtures/scopes/c/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..52ce5e54b4 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.multiLine.scope @@ -0,0 +1,24 @@ +foo( + aaa, + bbb +); +--- + +[Content] = +[Removal] = 0:4-3:0 + > +0| foo( +1| aaa, +2| bbb +3| ); + < + +[Domain] = 0:0-3:1 + >---- +0| foo( +1| aaa, +2| bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/c/argumentList.actual.singleLine.scope b/data/fixtures/scopes/c/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..d649112ab5 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.actual.singleLine.scope @@ -0,0 +1,13 @@ +foo(aaa, bbb); +--- + +[Content] = +[Removal] = 0:4-0:12 + >--------< +0| foo(aaa, bbb); + +[Domain] = 0:0-0:13 + >-------------< +0| foo(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/c/argumentList.formal.empty.scope b/data/fixtures/scopes/c/argumentList.formal.empty.scope new file mode 100644 index 0000000000..9d4dd443f0 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.formal.empty.scope @@ -0,0 +1,13 @@ +void foo() {} +--- + +[Content] = +[Removal] = 0:9-0:9 + >< +0| void foo() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/c/argumentList.formal.multiLine.scope b/data/fixtures/scopes/c/argumentList.formal.multiLine.scope new file mode 100644 index 0000000000..ec777f93f9 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.formal.multiLine.scope @@ -0,0 +1,24 @@ +void foo( + int aaa, + int bbb +) {} +--- + +[Content] = +[Removal] = 0:9-3:0 + > +0| void foo( +1| int aaa, +2| int bbb +3| ) {} + < + +[Domain] = 0:0-3:4 + >--------- +0| void foo( +1| int aaa, +2| int bbb +3| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/c/argumentList.formal.singleLine.scope b/data/fixtures/scopes/c/argumentList.formal.singleLine.scope new file mode 100644 index 0000000000..b0b45fbd71 --- /dev/null +++ b/data/fixtures/scopes/c/argumentList.formal.singleLine.scope @@ -0,0 +1,13 @@ +void foo(int aaa, int bbb) {} +--- + +[Content] = +[Removal] = 0:9-0:25 + >----------------< +0| void foo(int aaa, int bbb) {} + +[Domain] = 0:0-0:29 + >-----------------------------< +0| void foo(int aaa, int bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/c/branch.if.iteration.scope b/data/fixtures/scopes/c/branch.if.iteration.scope new file mode 100644 index 0000000000..86acdd382f --- /dev/null +++ b/data/fixtures/scopes/c/branch.if.iteration.scope @@ -0,0 +1,12 @@ +if (true) {} +else if (false) {} +else {} +--- + +[Range] = +[Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< diff --git a/data/fixtures/scopes/c/branch.if.scope b/data/fixtures/scopes/c/branch.if.scope new file mode 100644 index 0000000000..8bf55324af --- /dev/null +++ b/data/fixtures/scopes/c/branch.if.scope @@ -0,0 +1,45 @@ +if (true) {} +else if (false) {} +else {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| if (true) {} + +[#1 Removal] = 0:0-1:5 + >------------ +0| if (true) {} +1| else if (false) {} + -----< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:18 + >------------------< +1| else if (false) {} + +[#2 Removal] = 1:0-2:0 + >------------------ +1| else if (false) {} +2| else {} + < + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:0-2:7 + >-------< +2| else {} + +[#3 Removal] = 1:18-2:7 + > +1| else if (false) {} +2| else {} + -------< + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/branch.loop.scope b/data/fixtures/scopes/c/branch.loop.scope new file mode 100644 index 0000000000..b17e514454 --- /dev/null +++ b/data/fixtures/scopes/c/branch.loop.scope @@ -0,0 +1,10 @@ +for (int i = 0; i < size; ++i) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:33 + >---------------------------------< +0| for (int i = 0; i < size; ++i) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/branch.loop2.scope b/data/fixtures/scopes/c/branch.loop2.scope new file mode 100644 index 0000000000..5aaf57be8f --- /dev/null +++ b/data/fixtures/scopes/c/branch.loop2.scope @@ -0,0 +1,10 @@ +while (true) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| while (true) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/branch.loop3.scope b/data/fixtures/scopes/c/branch.loop3.scope new file mode 100644 index 0000000000..e1e74c9153 --- /dev/null +++ b/data/fixtures/scopes/c/branch.loop3.scope @@ -0,0 +1,10 @@ +do {} while (true); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| do {} while (true); + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/branch.switchCase.iteration.scope b/data/fixtures/scopes/c/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..909be76c4a --- /dev/null +++ b/data/fixtures/scopes/c/branch.switchCase.iteration.scope @@ -0,0 +1,27 @@ +switch (value) { + case 0: + break; + default: + break; +} +--- + +[Range] = 0:16-5:0 + > +0| switch (value) { +1| case 0: +2| break; +3| default: +4| break; +5| } + < + +[Domain] = 0:0-5:1 + >---------------- +0| switch (value) { +1| case 0: +2| break; +3| default: +4| break; +5| } + -< diff --git a/data/fixtures/scopes/c/branch.switchCase.scope b/data/fixtures/scopes/c/branch.switchCase.scope new file mode 100644 index 0000000000..4293cd1503 --- /dev/null +++ b/data/fixtures/scopes/c/branch.switchCase.scope @@ -0,0 +1,48 @@ +switch (value) { + case 0: + break; + default: + break; +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-2:14 + >------- +1| case 0: +2| break; + --------------< + +[#1 Removal] = 1:0-3:0 + >----------- +1| case 0: +2| break; +3| default: + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| case 0: + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 3:4-4:14 + >-------- +3| default: +4| break; + --------------< + +[#2 Removal] = 3:0-5:0 + >------------ +3| default: +4| break; +5| } + < + +[#2 Leading delimiter] = 3:0-3:4 + >----< +3| default: + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/branch.ternary.scope b/data/fixtures/scopes/c/branch.ternary.scope new file mode 100644 index 0000000000..9d12750feb --- /dev/null +++ b/data/fixtures/scopes/c/branch.ternary.scope @@ -0,0 +1,37 @@ +true ? 0 : 1; +--- + +[#1 Content] = +[#1 Domain] = 0:7-0:8 + >-< +0| true ? 0 : 1; + +[#1 Removal] = 0:7-0:9 + >--< +0| true ? 0 : 1; + +[#1 Leading delimiter] = 0:6-0:7 + >-< +0| true ? 0 : 1; + +[#1 Trailing delimiter] = 0:8-0:9 + >-< +0| true ? 0 : 1; + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| true ? 0 : 1; + +[#2 Removal] = 0:10-0:12 + >--< +0| true ? 0 : 1; + +[#2 Leading delimiter] = 0:10-0:11 + >-< +0| true ? 0 : 1; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/c/class.iteration.document.scope b/data/fixtures/scopes/c/class.iteration.document.scope new file mode 100644 index 0000000000..732f409fd3 --- /dev/null +++ b/data/fixtures/scopes/c/class.iteration.document.scope @@ -0,0 +1,12 @@ + +struct Foo {}; + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| struct Foo {}; +2| + < diff --git a/data/fixtures/scopes/c/class.scope b/data/fixtures/scopes/c/class.scope index 8888978407..d851092048 100644 --- a/data/fixtures/scopes/c/class.scope +++ b/data/fixtures/scopes/c/class.scope @@ -1,10 +1,6 @@ struct aaa { int bbb; }; -union bbb { int ccc; }; -enum ccc { ddd, eee }; typedef struct { int fff; } ggg; -typedef union { int hhh; } iii; -typedef enum { jjj, kkk } lll; --- [#1 Content] = @@ -12,80 +8,26 @@ typedef enum { jjj, kkk } lll; >------------------------< 0| struct aaa { int bbb; }; -[#1 Removal] = 0:0-1:0 +[#1 Removal] = 0:0-2:0 >------------------------ 0| struct aaa { int bbb; }; -1| union bbb { int ccc; }; +1| +2| typedef struct { int fff; } ggg; < [#1 Insertion delimiter] = "\n\n" [#2 Content] = -[#2 Domain] = 1:0-1:23 - >-----------------------< -1| union bbb { int ccc; }; - -[#2 Removal] = 1:0-2:0 - >----------------------- -1| union bbb { int ccc; }; -2| enum ccc { ddd, eee }; - < - -[#2 Insertion delimiter] = "\n\n" - - -[#3 Content] = -[#3 Domain] = 2:0-2:22 - >----------------------< -2| enum ccc { ddd, eee }; - -[#3 Removal] = 2:0-3:0 - >---------------------- -2| enum ccc { ddd, eee }; -3| - < - -[#3 Insertion delimiter] = "\n\n" - - -[#4 Content] = -[#4 Domain] = 4:0-4:32 +[#2 Domain] = 2:0-2:32 >--------------------------------< -4| typedef struct { int fff; } ggg; +2| typedef struct { int fff; } ggg; -[#4 Removal] = 4:0-5:0 - >-------------------------------- -4| typedef struct { int fff; } ggg; -5| typedef union { int hhh; } iii; - < - -[#4 Insertion delimiter] = "\n\n" - - -[#5 Content] = -[#5 Domain] = 5:0-5:31 - >-------------------------------< -5| typedef union { int hhh; } iii; - -[#5 Removal] = 5:0-6:0 - >------------------------------- -5| typedef union { int hhh; } iii; -6| typedef enum { jjj, kkk } lll; - < - -[#5 Insertion delimiter] = "\n\n" - - -[#6 Content] = -[#6 Domain] = 6:0-6:30 - >------------------------------< -6| typedef enum { jjj, kkk } lll; - -[#6 Removal] = 5:31-6:30 - > -5| typedef union { int hhh; } iii; -6| typedef enum { jjj, kkk } lll; - ------------------------------< +[#2 Removal] = 0:24-2:32 + > +0| struct aaa { int bbb; }; +1| +2| typedef struct { int fff; } ggg; + --------------------------------< -[#6 Insertion delimiter] = "\n\n" +[#2 Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/c/class2.scope b/data/fixtures/scopes/c/class2.scope new file mode 100644 index 0000000000..bc5988ab0c --- /dev/null +++ b/data/fixtures/scopes/c/class2.scope @@ -0,0 +1,33 @@ +union bbb { int ccc; }; + +typedef union { int hhh; } iii; +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:23 + >-----------------------< +0| union bbb { int ccc; }; + +[#1 Removal] = 0:0-2:0 + >----------------------- +0| union bbb { int ccc; }; +1| +2| typedef union { int hhh; } iii; + < + +[#1 Insertion delimiter] = "\n\n" + + +[#2 Content] = +[#2 Domain] = 2:0-2:31 + >-------------------------------< +2| typedef union { int hhh; } iii; + +[#2 Removal] = 0:23-2:31 + > +0| union bbb { int ccc; }; +1| +2| typedef union { int hhh; } iii; + -------------------------------< + +[#2 Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/c/class3.scope b/data/fixtures/scopes/c/class3.scope new file mode 100644 index 0000000000..682ccd1e92 --- /dev/null +++ b/data/fixtures/scopes/c/class3.scope @@ -0,0 +1,33 @@ +enum ccc { ddd, eee }; + +typedef enum { jjj, kkk } lll; +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:22 + >----------------------< +0| enum ccc { ddd, eee }; + +[#1 Removal] = 0:0-2:0 + >---------------------- +0| enum ccc { ddd, eee }; +1| +2| typedef enum { jjj, kkk } lll; + < + +[#1 Insertion delimiter] = "\n\n" + + +[#2 Content] = +[#2 Domain] = 2:0-2:30 + >------------------------------< +2| typedef enum { jjj, kkk } lll; + +[#2 Removal] = 0:22-2:30 + > +0| enum ccc { ddd, eee }; +1| +2| typedef enum { jjj, kkk } lll; + ------------------------------< + +[#2 Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/c/className.iteration.document.scope b/data/fixtures/scopes/c/className.iteration.document.scope new file mode 100644 index 0000000000..732f409fd3 --- /dev/null +++ b/data/fixtures/scopes/c/className.iteration.document.scope @@ -0,0 +1,12 @@ + +struct Foo {}; + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| struct Foo {}; +2| + < diff --git a/data/fixtures/scopes/c/collectionItem.unenclosed.iteration.scope b/data/fixtures/scopes/c/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..667786128a --- /dev/null +++ b/data/fixtures/scopes/c/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,10 @@ +int foo, bar; +--- + +[Range] = 0:4-0:12 + >--------< +0| int foo, bar; + +[Domain] = 0:0-0:13 + >-------------< +0| int foo, bar; diff --git a/data/fixtures/scopes/c/collectionItem.unenclosed.scope b/data/fixtures/scopes/c/collectionItem.unenclosed.scope new file mode 100644 index 0000000000..c66d14c45e --- /dev/null +++ b/data/fixtures/scopes/c/collectionItem.unenclosed.scope @@ -0,0 +1,65 @@ +int foo, bar; +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:7 + >-------< +0| int foo, bar; + +[#1 Removal] = 0:0-0:9 + >---------< +0| int foo, bar; + +[#1 Trailing delimiter] = 0:7-0:9 + >--< +0| int foo, bar; + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:7 + >---< +0| int foo, bar; + +[#2 Removal] = 0:3-0:7 + >----< +0| int foo, bar; + +[#2 Leading delimiter] = 0:3-0:4 + >-< +0| int foo, bar; + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 0:9-0:12 + >---< +0| int foo, bar; + +[#3 Removal] = 0:8-0:12 + >----< +0| int foo, bar; + +[#3 Leading delimiter] = 0:8-0:9 + >-< +0| int foo, bar; + +[#3 Insertion delimiter] = "\n" + + +[#4 Content] = +[#4 Domain] = 0:9-0:13 + >----< +0| int foo, bar; + +[#4 Removal] = 0:7-0:13 + >------< +0| int foo, bar; + +[#4 Leading delimiter] = 0:7-0:9 + >--< +0| int foo, bar; + +[#4 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/c/condition.doWhile.scope b/data/fixtures/scopes/c/condition.doWhile.scope new file mode 100644 index 0000000000..f8e3242e13 --- /dev/null +++ b/data/fixtures/scopes/c/condition.doWhile.scope @@ -0,0 +1,13 @@ +do {} while (true); +--- + +[Content] = +[Removal] = 0:13-0:17 + >----< +0| do {} while (true); + +[Domain] = 0:0-0:19 + >-------------------< +0| do {} while (true); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/condition.for.scope b/data/fixtures/scopes/c/condition.for.scope new file mode 100644 index 0000000000..4a0bb6a2d3 --- /dev/null +++ b/data/fixtures/scopes/c/condition.for.scope @@ -0,0 +1,20 @@ +for (int i = 0; i < size; ++i) {} +--- + +[Content] = 0:16-0:24 + >--------< +0| for (int i = 0; i < size; ++i) {} + +[Removal] = 0:15-0:24 + >---------< +0| for (int i = 0; i < size; ++i) {} + +[Leading delimiter] = 0:15-0:16 + >-< +0| for (int i = 0; i < size; ++i) {} + +[Domain] = 0:0-0:33 + >---------------------------------< +0| for (int i = 0; i < size; ++i) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/condition.if.scope b/data/fixtures/scopes/c/condition.if.scope new file mode 100644 index 0000000000..4f5ac14fc6 --- /dev/null +++ b/data/fixtures/scopes/c/condition.if.scope @@ -0,0 +1,30 @@ +if (true) {} +else if (false) {} +else {} +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:8 + >----< +0| if (true) {} + +[#1 Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:14 + >-----< +1| else if (false) {} + +[#2 Domain] = 1:0-1:18 + >------------------< +1| else if (false) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/condition.switchCase.iteration.scope b/data/fixtures/scopes/c/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..e236bec91b --- /dev/null +++ b/data/fixtures/scopes/c/condition.switchCase.iteration.scope @@ -0,0 +1,10 @@ +switch (value) { } +--- + +[Range] = 0:16-0:17 + >-< +0| switch (value) { } + +[Domain] = 0:0-0:18 + >------------------< +0| switch (value) { } diff --git a/data/fixtures/scopes/c/condition.switchCase.scope b/data/fixtures/scopes/c/condition.switchCase.scope new file mode 100644 index 0000000000..529eefb74b --- /dev/null +++ b/data/fixtures/scopes/c/condition.switchCase.scope @@ -0,0 +1,25 @@ +switch (value) { + case 0: + break; +} +--- + +[Content] = 1:9-1:10 + >-< +1| case 0: + +[Removal] = 1:8-1:10 + >--< +1| case 0: + +[Leading delimiter] = 1:8-1:9 + >-< +1| case 0: + +[Domain] = 1:4-2:14 + >------- +1| case 0: +2| break; + --------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/condition.ternary.scope b/data/fixtures/scopes/c/condition.ternary.scope new file mode 100644 index 0000000000..2b6cdb301a --- /dev/null +++ b/data/fixtures/scopes/c/condition.ternary.scope @@ -0,0 +1,20 @@ +true ? 0 : 1 +--- + +[Content] = 0:0-0:4 + >----< +0| true ? 0 : 1 + +[Removal] = 0:0-0:5 + >-----< +0| true ? 0 : 1 + +[Trailing delimiter] = 0:4-0:5 + >-< +0| true ? 0 : 1 + +[Domain] = 0:0-0:12 + >------------< +0| true ? 0 : 1 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/condition.while.scope b/data/fixtures/scopes/c/condition.while.scope new file mode 100644 index 0000000000..61cd7d9e7a --- /dev/null +++ b/data/fixtures/scopes/c/condition.while.scope @@ -0,0 +1,13 @@ +while (true) {} +--- + +[Content] = +[Removal] = 0:7-0:11 + >----< +0| while (true) {} + +[Domain] = 0:0-0:15 + >---------------< +0| while (true) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/functionName.iteration.document.scope b/data/fixtures/scopes/c/functionName.iteration.document.scope new file mode 100644 index 0000000000..9f52edea4d --- /dev/null +++ b/data/fixtures/scopes/c/functionName.iteration.document.scope @@ -0,0 +1,12 @@ + +void foo() {} + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| void foo() {} +2| + < diff --git a/data/fixtures/scopes/c/name.argument.formal.iteration.scope b/data/fixtures/scopes/c/name.argument.formal.iteration.scope index a4170509a0..0fc17b3c8e 100644 --- a/data/fixtures/scopes/c/name.argument.formal.iteration.scope +++ b/data/fixtures/scopes/c/name.argument.formal.iteration.scope @@ -1,7 +1,13 @@ void aaa(int bbb, int ccc); --- -[Range] = -[Domain] = 0:9-0:25 +[#1 Range] = +[#1 Domain] = 0:0-0:27 + >---------------------------< +0| void aaa(int bbb, int ccc); + + +[#2 Range] = +[#2 Domain] = 0:9-0:25 >----------------< 0| void aaa(int bbb, int ccc); diff --git a/data/fixtures/scopes/c/name.argument.formal.iteration2.scope b/data/fixtures/scopes/c/name.argument.formal.iteration2.scope index 0d23c6cea3..4d651af334 100644 --- a/data/fixtures/scopes/c/name.argument.formal.iteration2.scope +++ b/data/fixtures/scopes/c/name.argument.formal.iteration2.scope @@ -1,7 +1,19 @@ void aaa(int bbb, int ccc) {} --- -[Range] = -[Domain] = 0:9-0:25 +[#1 Range] = +[#1 Domain] = 0:0-0:29 + >-----------------------------< +0| void aaa(int bbb, int ccc) {} + + +[#2 Range] = +[#2 Domain] = 0:9-0:25 >----------------< 0| void aaa(int bbb, int ccc) {} + + +[#3 Range] = +[#3 Domain] = 0:28-0:28 + >< +0| void aaa(int bbb, int ccc) {} diff --git a/data/fixtures/scopes/c/name.iteration.block.scope b/data/fixtures/scopes/c/name.iteration.block.scope new file mode 100644 index 0000000000..95df2cd3c4 --- /dev/null +++ b/data/fixtures/scopes/c/name.iteration.block.scope @@ -0,0 +1,13 @@ +if (true) { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + + +[#2 Range] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } diff --git a/data/fixtures/scopes/c/name.iteration.block2.scope b/data/fixtures/scopes/c/name.iteration.block2.scope new file mode 100644 index 0000000000..73e54b7c16 --- /dev/null +++ b/data/fixtures/scopes/c/name.iteration.block2.scope @@ -0,0 +1,19 @@ +void foo() { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Range] = +[#2 Domain] = 0:9-0:9 + >< +0| void foo() { } + + +[#3 Range] = +[#3 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/c/name.iteration.document.scope b/data/fixtures/scopes/c/name.iteration.document.scope new file mode 100644 index 0000000000..3e0daecfa3 --- /dev/null +++ b/data/fixtures/scopes/c/name.iteration.document.scope @@ -0,0 +1,12 @@ + +int foo; + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| int foo; +2| + < diff --git a/data/fixtures/scopes/c/namedFunction.iteration.document.scope b/data/fixtures/scopes/c/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..80049bb80e --- /dev/null +++ b/data/fixtures/scopes/c/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +void foo() { } + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| void foo() { } +2| + < diff --git a/data/fixtures/scopes/c/statement.iteration.block.scope b/data/fixtures/scopes/c/statement.iteration.block.scope new file mode 100644 index 0000000000..95df2cd3c4 --- /dev/null +++ b/data/fixtures/scopes/c/statement.iteration.block.scope @@ -0,0 +1,13 @@ +if (true) { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + + +[#2 Range] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } diff --git a/data/fixtures/scopes/c/statement.iteration.block2.scope b/data/fixtures/scopes/c/statement.iteration.block2.scope new file mode 100644 index 0000000000..dd07df8311 --- /dev/null +++ b/data/fixtures/scopes/c/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +void foo() { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Range] = +[#2 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/c/statement.iteration.document.scope b/data/fixtures/scopes/c/statement.iteration.document.scope new file mode 100644 index 0000000000..3e0daecfa3 --- /dev/null +++ b/data/fixtures/scopes/c/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +int foo; + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| int foo; +2| + < diff --git a/data/fixtures/scopes/c/switchStatementSubject.scope b/data/fixtures/scopes/c/switchStatementSubject.scope new file mode 100644 index 0000000000..67688ae8d0 --- /dev/null +++ b/data/fixtures/scopes/c/switchStatementSubject.scope @@ -0,0 +1,13 @@ +switch (value) {} +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) {} + +[Domain] = 0:0-0:17 + >-----------------< +0| switch (value) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/c/type.argument.formal.iteration.scope b/data/fixtures/scopes/c/type.argument.formal.iteration.scope new file mode 100644 index 0000000000..457e904030 --- /dev/null +++ b/data/fixtures/scopes/c/type.argument.formal.iteration.scope @@ -0,0 +1,7 @@ +void foo(int aaa, int bbb) {} +--- + +[Range] = +[Domain] = 0:9-0:25 + >----------------< +0| void foo(int aaa, int bbb) {} diff --git a/data/fixtures/scopes/c/type.field.iteration.scope b/data/fixtures/scopes/c/type.field.iteration.scope new file mode 100644 index 0000000000..70e202299c --- /dev/null +++ b/data/fixtures/scopes/c/type.field.iteration.scope @@ -0,0 +1,7 @@ +struct Foo { }; +--- + +[Range] = +[Domain] = 0:12-0:13 + >-< +0| struct Foo { }; diff --git a/data/fixtures/scopes/c/value.return.scope b/data/fixtures/scopes/c/value.return.scope new file mode 100644 index 0000000000..87605fdbf8 --- /dev/null +++ b/data/fixtures/scopes/c/value.return.scope @@ -0,0 +1,22 @@ +int foo() { + 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/cpp/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope index d75a3ce2e3..68f7d20468 100644 --- a/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/cpp/name.argument.formal.constructor.iteration.scope @@ -3,7 +3,22 @@ class MyClass { } --- -[Range] = -[Domain] = 1:12-1:32 +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >--------------- +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) {} + + +[#3 Range] = +[#3 Domain] = 1:35-1:35 + >< +1| MyClass(int aaa, int bbb = 2) {} diff --git a/data/fixtures/scopes/cpp/name.argument.formal.iteration.scope b/data/fixtures/scopes/cpp/name.argument.formal.iteration.scope index c42713d2a2..c94fac1f7f 100644 --- a/data/fixtures/scopes/cpp/name.argument.formal.iteration.scope +++ b/data/fixtures/scopes/cpp/name.argument.formal.iteration.scope @@ -1,7 +1,19 @@ void aaa(int bbb = 0, int ccc = 0) {} --- -[Range] = -[Domain] = 0:9-0:33 +[#1 Range] = +[#1 Domain] = 0:0-0:37 + >-------------------------------------< +0| void aaa(int bbb = 0, int ccc = 0) {} + + +[#2 Range] = +[#2 Domain] = 0:9-0:33 >------------------------< 0| void aaa(int bbb = 0, int ccc = 0) {} + + +[#3 Range] = +[#3 Domain] = 0:36-0:36 + >< +0| void aaa(int bbb = 0, int ccc = 0) {} 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 ee053b4452..ad30506e8a 100644 --- a/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/cpp/name.argument.formal.method.iteration.scope @@ -3,7 +3,22 @@ class MyClass { } --- -[Range] = -[Domain] = 1:13-1:33 +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >--------------- +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) {} + + +[#3 Range] = +[#3 Domain] = 1:36-1:36 + >< +1| void foo(int aaa, int bbb = 2) {} diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index e5e219b912..921f04d24e 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -5,16 +5,31 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { list: supported, + disqualifyDelimiter: supported, + switchStatementSubject: supported, + ifStatement: supported, statement: supported, "statement.class": supported, + "statement.iteration.document": supported, + "statement.iteration.block": supported, + class: supported, + "class.iteration.document": supported, className: supported, - namedFunction: supported, + "className.iteration.document": supported, + "collectionItem.unenclosed": supported, + "collectionItem.unenclosed.iteration": supported, + + namedFunction: supported, functionName: supported, + "functionName.iteration.document": supported, + "namedFunction.iteration.document": supported, + functionCall: supported, functionCallee: supported, + "argument.actual": supported, "argument.actual.iteration": supported, "argument.actual.method": supported, @@ -22,27 +37,54 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal": supported, "argument.formal.iteration": supported, + "argumentList.actual.empty": supported, + "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + "argumentList.formal.empty": supported, + "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + + "branch.if": supported, + "branch.if.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.loop": supported, + "comment.line": supported, "comment.block": supported, "string.singleLine": supported, "textFragment.comment.line": supported, "textFragment.comment.block": supported, "textFragment.string.singleLine": supported, - disqualifyDelimiter: supported, + + "condition.if": supported, + "condition.while": supported, + "condition.doWhile": supported, + "condition.for": supported, + "condition.ternary": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, "name.assignment": supported, "name.variable": supported, "name.function": supported, "name.class": supported, "name.field": supported, + "name.iteration.block": supported, + "name.iteration.document": supported, "name.argument.formal": supported, "name.argument.formal.iteration": supported, + "value.assignment": supported, "value.variable": supported, + "value.return": supported, "type.variable": supported, "type.argument.formal": supported, + "type.argument.formal.iteration": supported, "type.field": supported, + "type.field.iteration": supported, "type.enum": supported, "type.cast": supported, "type.class": supported, @@ -50,61 +92,14 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { // Unsupported - switchStatementSubject: unsupported, - fieldAccess: unsupported, - - "argumentList.actual.empty": unsupported, - "argumentList.actual.singleLine": unsupported, - "argumentList.actual.multiLine": unsupported, - "argumentList.formal.empty": unsupported, - "argumentList.formal.singleLine": unsupported, - "argumentList.formal.multiLine": unsupported, - - "statement.iteration.document": unsupported, - "statement.iteration.block": unsupported, - - "class.iteration.document": unsupported, - "className.iteration.document": unsupported, - - "functionName.iteration.document": unsupported, - "namedFunction.iteration.document": unsupported, - "interior.class": unsupported, "interior.function": unsupported, "interior.if": unsupported, - "interior.try": unsupported, "interior.switchCase": unsupported, "interior.ternary": unsupported, "interior.loop": unsupported, - "branch.if": unsupported, - "branch.if.iteration": unsupported, - "branch.try": unsupported, - "branch.try.iteration": unsupported, - "branch.switchCase": unsupported, - "branch.switchCase.iteration": unsupported, - "branch.ternary": unsupported, - "branch.loop": unsupported, - - "condition.if": unsupported, - "condition.while": unsupported, - "condition.doWhile": unsupported, - "condition.for": unsupported, - "condition.ternary": unsupported, - "condition.switchCase": unsupported, - "condition.switchCase.iteration": unsupported, - - "collectionItem.unenclosed": unsupported, - "collectionItem.unenclosed.iteration": unsupported, - - "name.iteration.block": unsupported, - "name.iteration.document": unsupported, - - "value.return": unsupported, - "value.field": unsupported, - - "type.field.iteration": unsupported, - "type.argument.formal.iteration": unsupported, + fieldAccess: unsupported, // Not applicable (C and C++) @@ -168,11 +163,17 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "class.iteration.block": notApplicable, "className.iteration.block": notApplicable, + // Try catch + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + "interior.try": notApplicable, + // Miscellaneous "key.attribute": notApplicable, "type.interface": notApplicable, "value.attribute": notApplicable, "value.yield": notApplicable, + "value.field": notApplicable, environment: notApplicable, pairDelimiter: notApplicable, regularExpression: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/cpp.ts b/packages/common/src/scopeSupportFacets/cpp.ts index 37c9a07484..48734ba21e 100644 --- a/packages/common/src/scopeSupportFacets/cpp.ts +++ b/packages/common/src/scopeSupportFacets/cpp.ts @@ -15,12 +15,14 @@ export const cppScopeSupport: LanguageScopeSupportFacetMap = { attribute: supported, anonymousFunction: supported, + "value.argument.formal": supported, "value.argument.formal.iteration": supported, "value.argument.formal.method": supported, "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, @@ -71,6 +73,7 @@ export const cppScopeSupport: LanguageScopeSupportFacetMap = { "value.foreach": unsupported, "value.return.lambda": unsupported, + "value.field": unsupported, "type.typeArgument": unsupported, "type.typeArgument.iteration": unsupported, @@ -78,4 +81,8 @@ export const cppScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal.constructor.iteration": unsupported, "interior.lambda": unsupported, + + "branch.try": unsupported, + "branch.try.iteration": unsupported, + "interior.try": unsupported, }; diff --git a/queries/c.scm b/queries/c.scm index 813eae8bb7..46a4b8856b 100644 --- a/queries/c.scm +++ b/queries/c.scm @@ -15,7 +15,6 @@ (type_definition) (break_statement) (case_statement) - (compound_statement) (continue_statement) (do_statement) (expression_statement) @@ -26,10 +25,32 @@ (return_statement) (switch_statement) (while_statement) + ;; Disabled on purpose. This is the entire body of statements. + ;; (compound_statement) ] @statement (if_statement) @ifStatement +( + (translation_unit) @statement.iteration @class.iteration @className.iteration + (#document-range! @statement.iteration @class.iteration @className.iteration) +) +( + (translation_unit) @namedFunction.iteration @functionName.iteration @name.iteration + (#document-range! @namedFunction.iteration @functionName.iteration @name.iteration) +) + +(field_declaration_list + "{" @type.iteration.start.endOf + "}" @type.iteration.end.startOf +) + +;; Body of statements +(compound_statement + "{" @statement.iteration.start.endOf @name.iteration.start.endOf + "}" @statement.iteration.end.startOf @name.iteration.end.startOf +) + ( (string_literal) @string @textFragment (#child-range! @textFragment 0 -1 true true) @@ -160,12 +181,6 @@ function: (_) @functionCallee ) @_.domain -(switch_statement - condition: (_ - value: (_) @private.switchStatementSubject - ) -) @_.domain - ;;!! int aaa = 0; (declaration declarator: (_ @@ -206,14 +221,14 @@ ")" @type.removal.end ) @_.domain -;;!! void foo(int value) {} -;;! ^^^^^ +;;!! void foo(int aaa) {} +;;! ^^^ (parameter_declaration declarator: (_) @name ) @_.domain -;;!! void foo(int value) {} -;;! ^^^^^^^^^ +;;!! void foo(int aaa, int bbb) {} +;;! ^^^^^^^ ^^^^^^^ ( (parameter_list (_)? @_.leading.endOf @@ -226,8 +241,8 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) -;;!! foo(5 + 6) -;;! ^^^^^ +;;!! foo(aaa, bbb); +;;! ^^^ ^^^ ( (argument_list (_)? @_.leading.endOf @@ -240,21 +255,147 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! void foo(int aaa, int bbb) {} +;;! ^^^^^^^^^^^^^^^^ (_ (function_declarator (parameter_list - "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf - ) + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) @_dummy ) -) @argumentOrParameter.iteration.domain + (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain +(parameter_list + "(" @type.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf + ")" @type.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf +) + +;;!! foo(aaa, bbb); +;;! ^^^^^^^^ (_ (argument_list - "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) @_dummy + (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain + +;;!! if () {} +;;! ^^^^^^^^ +( + (if_statement + "if" @branch.start @branch.removal.start + condition: (_) @condition + consequence: (_) @branch.end @branch.removal.end + alternative: (else_clause + (if_statement) @branch.removal.end.startOf + )? + ) @condition.domain + (#not-parent-type? @condition.domain "else_clause") + (#child-range! @condition 0 -1 true true) +) + +;;!! else if () {} +;;! ^^^^^^^^^^^^^ +(else_clause + "else" @branch.start @condition.domain.start + (if_statement + condition: (_) @condition + consequence: (_) @branch.end @condition.domain.end + (#child-range! @condition 0 -1 true true) + ) +) + +;;!! else {} +;;! ^^^^^^^ +(if_statement + (else_clause + (compound_statement) + ) @branch +) + +( + (if_statement) @branch.iteration + (#not-parent-type? @branch.iteration "else_clause") +) + +;;!! for (int i = 0; i < size; ++i) {} +;;! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^ +(for_statement + condition: (_) @condition +) @branch @condition.domain + +;;!! while (true) {} +;;! ^^^^^^^^^^^^^^^ +;;! ^^^^ +(while_statement + condition: (_) @condition + (#child-range! @condition 0 -1 true true) +) @branch @condition.domain + +;;!! do {} while (true); +;;! ^^^^^^^^^^^^^^^^^^^ +;;! ^^^^ +(do_statement + condition: (_) @condition + (#child-range! @condition 0 -1 true true) +) @branch @condition.domain + +;;!! switch (true) {} +;;! ^^^^ +(switch_statement + condition: (_ + "(" @private.switchStatementSubject.start.endOf + ")" @private.switchStatementSubject.end.startOf + ) + body: (_ + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf ) -) @argumentOrParameter.iteration.domain +) @_.domain @branch.iteration.domain @condition.iteration.domain + +;;!! case 0: break; +;;! ^^^^^^^^^^^^^^ +;;! ^ +(case_statement + value: (_)? @condition +) @branch @condition.domain + +;;!! true ? 0 : 1 +;;! ^^^^ +;;! ^ ^ +(conditional_expression + condition: (_) @condition + consequence: (_) @branch +) @condition.domain +(conditional_expression + alternative: (_) @branch +) + +;;!! int foo, bar; +;;! ^^^ ^^^ +(declaration + type: (_) + (_) @collectionItem +) + +(declaration + type: (_) + . + (_) @collectionItem.iteration.start + (_)? @collectionItem.iteration.end + . +) @collectionItem.iteration.domain + +;;!! return 0; +;;! ^ +(return_statement + "return" + (_) @value +) @_.domain operator: [ "->" diff --git a/queries/java.scm b/queries/java.scm index 2b74e4e0b4..d079c7e07f 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -181,10 +181,8 @@ (switch_expression body: (_ - . "{" @branch.iteration.start.endOf @condition.iteration.start.endOf "}" @condition.iteration.end.startOf @branch.iteration.end.startOf - . ) ) @condition.iteration.domain @branch.iteration.domain @@ -489,8 +487,8 @@ ">" @type.iteration.end.startOf ) -;;!! foo(name: string) {} -;;! ^^^^^^^^^^^^ +;;!! void foo(int aaa, int bbb) {} +;;! ^^^^^^^ ^^^^^^^ (_ parameters: (_ (_)? @_.leading.endOf @@ -503,8 +501,8 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) -;;!! foo("bar") -;;! ^^^^^ +;;!! foo(aaa, bbb); +;;! ^^^ ^^^ ( (argument_list (_)? @_.leading.endOf @@ -517,8 +515,8 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) -;;!! foo(int a) {}; -;;! ^^^^^ +;;!! void foo(int aaa, int bbb) {} +;;! ^^^^^^^^^^^^^^^^ (_ parameters: (_ "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf @@ -527,8 +525,8 @@ (#empty-single-multi-delimiter! @argumentList.start.endOf @_dummy "" ", " ",\n") ) @argumentList.domain @argumentOrParameter.iteration.domain -;;!! foo(1); -;;! ^ +;;!! foo(aaa, bbb); +;;! ^^^^^^^^ (_ (argument_list "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf