From ae4f816f8bc4caba32d64aefe4c67af5fcc28a61 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 11 Feb 2025 19:07:11 +0100 Subject: [PATCH 1/6] Adding java facets --- .../scopes/java/anonymousFunction.scope | 10 ++ .../scopes/java/anonymousFunction2.scope | 15 ++ ...rgument.actual.constructor.iteration.scope | 10 ++ .../java/argument.actual.constructor.scope | 33 ++++ .../argument.actual.method.iteration.scope | 10 ++ .../scopes/java/argument.actual.method.scope | 33 ++++ ...rgument.formal.constructor.iteration.scope | 12 ++ .../java/argument.formal.constructor.scope | 35 ++++ .../argument.formal.method.iteration.scope | 12 ++ .../scopes/java/argument.formal.method.scope | 35 ++++ .../java/branch.switchCase.iteration.scope | 33 ++++ .../scopes/java/branch.switchCase.scope | 71 ++++++++ .../fixtures/scopes/java/branch.ternary.scope | 37 ++++ data/fixtures/scopes/java/class.scope | 10 ++ data/fixtures/scopes/java/className.scope | 24 +++ data/fixtures/scopes/java/comment.block.scope | 10 ++ data/fixtures/scopes/java/comment.line.scope | 10 ++ .../scopes/java/condition.doWhile.scope | 13 ++ data/fixtures/scopes/java/condition.for.scope | 20 +++ data/fixtures/scopes/java/condition.if.scope | 13 ++ .../java/condition.switchCase.iteration.scope | 33 ++++ .../scopes/java/condition.switchCase.scope | 50 ++++++ .../scopes/java/condition.ternary.scope | 20 +++ .../scopes/java/condition.while.scope | 13 ++ .../java/functionCall.constructor.scope | 10 ++ data/fixtures/scopes/java/functionCall.scope | 10 ++ .../java/functionCallee.constructor.scope | 13 ++ .../fixtures/scopes/java/functionCallee.scope | 13 ++ .../java/functionName.constructor.scope | 19 +++ .../scopes/java/functionName.method.scope | 19 +++ data/fixtures/scopes/java/ifStatement.scope | 10 ++ data/fixtures/scopes/java/list.scope | 10 ++ .../java/name.argument.formal.method.scope | 83 +++++++++ .../scopes/java/name.assignment.scope | 20 +++ data/fixtures/scopes/java/name.class.scope | 24 +++ .../scopes/java/name.constructor.scope | 45 +++++ data/fixtures/scopes/java/name.field.scope | 48 ++++++ data/fixtures/scopes/java/name.method.scope | 45 +++++ data/fixtures/scopes/java/name.variable.scope | 20 +++ .../scopes/java/namedFunction.method.scope | 21 +++ .../common/src/scopeSupportFacets/java.ts | 158 +++++++++++++++++- queries/java.scm | 9 +- 42 files changed, 1134 insertions(+), 5 deletions(-) create mode 100644 data/fixtures/scopes/java/anonymousFunction.scope create mode 100644 data/fixtures/scopes/java/anonymousFunction2.scope create mode 100644 data/fixtures/scopes/java/argument.actual.constructor.iteration.scope create mode 100644 data/fixtures/scopes/java/argument.actual.constructor.scope create mode 100644 data/fixtures/scopes/java/argument.actual.method.iteration.scope create mode 100644 data/fixtures/scopes/java/argument.actual.method.scope create mode 100644 data/fixtures/scopes/java/argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/java/argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/java/argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/java/argument.formal.method.scope create mode 100644 data/fixtures/scopes/java/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/java/branch.switchCase.scope create mode 100644 data/fixtures/scopes/java/branch.ternary.scope create mode 100644 data/fixtures/scopes/java/class.scope create mode 100644 data/fixtures/scopes/java/className.scope create mode 100644 data/fixtures/scopes/java/comment.block.scope create mode 100644 data/fixtures/scopes/java/comment.line.scope create mode 100644 data/fixtures/scopes/java/condition.doWhile.scope create mode 100644 data/fixtures/scopes/java/condition.for.scope create mode 100644 data/fixtures/scopes/java/condition.if.scope create mode 100644 data/fixtures/scopes/java/condition.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/java/condition.switchCase.scope create mode 100644 data/fixtures/scopes/java/condition.ternary.scope create mode 100644 data/fixtures/scopes/java/condition.while.scope create mode 100644 data/fixtures/scopes/java/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/java/functionCall.scope create mode 100644 data/fixtures/scopes/java/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/java/functionCallee.scope create mode 100644 data/fixtures/scopes/java/functionName.constructor.scope create mode 100644 data/fixtures/scopes/java/functionName.method.scope create mode 100644 data/fixtures/scopes/java/ifStatement.scope create mode 100644 data/fixtures/scopes/java/list.scope create mode 100644 data/fixtures/scopes/java/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/java/name.assignment.scope create mode 100644 data/fixtures/scopes/java/name.class.scope create mode 100644 data/fixtures/scopes/java/name.constructor.scope create mode 100644 data/fixtures/scopes/java/name.field.scope create mode 100644 data/fixtures/scopes/java/name.method.scope create mode 100644 data/fixtures/scopes/java/name.variable.scope create mode 100644 data/fixtures/scopes/java/namedFunction.method.scope diff --git a/data/fixtures/scopes/java/anonymousFunction.scope b/data/fixtures/scopes/java/anonymousFunction.scope new file mode 100644 index 0000000000..7e34880d05 --- /dev/null +++ b/data/fixtures/scopes/java/anonymousFunction.scope @@ -0,0 +1,10 @@ +() -> 2; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:7 + >-------< +0| () -> 2; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/anonymousFunction2.scope b/data/fixtures/scopes/java/anonymousFunction2.scope new file mode 100644 index 0000000000..62fcb08eff --- /dev/null +++ b/data/fixtures/scopes/java/anonymousFunction2.scope @@ -0,0 +1,15 @@ +(value) -> { + return value; +}; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >------------ +0| (value) -> { +1| return value; +2| }; + -< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/argument.actual.constructor.iteration.scope b/data/fixtures/scopes/java/argument.actual.constructor.iteration.scope new file mode 100644 index 0000000000..eeeef4b2ce --- /dev/null +++ b/data/fixtures/scopes/java/argument.actual.constructor.iteration.scope @@ -0,0 +1,10 @@ +new Foo(123, 456); +--- + +[Range] = 0:8-0:16 + >--------< +0| new Foo(123, 456); + +[Domain] = 0:7-0:17 + >----------< +0| new Foo(123, 456); diff --git a/data/fixtures/scopes/java/argument.actual.constructor.scope b/data/fixtures/scopes/java/argument.actual.constructor.scope new file mode 100644 index 0000000000..7f54786c3b --- /dev/null +++ b/data/fixtures/scopes/java/argument.actual.constructor.scope @@ -0,0 +1,33 @@ +new Foo(123, 456); +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:11 + >---< +0| new Foo(123, 456); + +[#1 Removal] = 0:8-0:13 + >-----< +0| new Foo(123, 456); + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| new Foo(123, 456); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| new Foo(123, 456); + +[#2 Removal] = 0:11-0:16 + >-----< +0| new Foo(123, 456); + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| new Foo(123, 456); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argument.actual.method.iteration.scope b/data/fixtures/scopes/java/argument.actual.method.iteration.scope new file mode 100644 index 0000000000..bfc40570a6 --- /dev/null +++ b/data/fixtures/scopes/java/argument.actual.method.iteration.scope @@ -0,0 +1,10 @@ +foo.bar(123, 456); +--- + +[Range] = 0:8-0:16 + >--------< +0| foo.bar(123, 456); + +[Domain] = 0:7-0:17 + >----------< +0| foo.bar(123, 456); diff --git a/data/fixtures/scopes/java/argument.actual.method.scope b/data/fixtures/scopes/java/argument.actual.method.scope new file mode 100644 index 0000000000..6501846622 --- /dev/null +++ b/data/fixtures/scopes/java/argument.actual.method.scope @@ -0,0 +1,33 @@ +foo.bar(123, 456); +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:11 + >---< +0| foo.bar(123, 456); + +[#1 Removal] = 0:8-0:13 + >-----< +0| foo.bar(123, 456); + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| foo.bar(123, 456); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| foo.bar(123, 456); + +[#2 Removal] = 0:11-0:16 + >-----< +0| foo.bar(123, 456); + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| foo.bar(123, 456); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/java/argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..d060457e02 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.constructor.iteration.scope @@ -0,0 +1,12 @@ +public class MyClass { + public MyClass(String name, int age) {} +} +--- + +[Range] = 1:19-1:39 + >--------------------< +1| public MyClass(String name, int age) {} + +[Domain] = 1:4-1:43 + >---------------------------------------< +1| public MyClass(String name, int age) {} diff --git a/data/fixtures/scopes/java/argument.formal.constructor.scope b/data/fixtures/scopes/java/argument.formal.constructor.scope new file mode 100644 index 0000000000..7f0b1de10b --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.constructor.scope @@ -0,0 +1,35 @@ +public class MyClass { + public MyClass(String name, int age) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:19-1:30 + >-----------< +1| public MyClass(String name, int age) {} + +[#1 Removal] = 1:19-1:32 + >-------------< +1| public MyClass(String name, int age) {} + +[#1 Trailing delimiter] = 1:30-1:32 + >--< +1| public MyClass(String name, int age) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:32-1:39 + >-------< +1| public MyClass(String name, int age) {} + +[#2 Removal] = 1:30-1:39 + >---------< +1| public MyClass(String name, int age) {} + +[#2 Leading delimiter] = 1:30-1:32 + >--< +1| public MyClass(String name, int age) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/argument.formal.method.iteration.scope b/data/fixtures/scopes/java/argument.formal.method.iteration.scope new file mode 100644 index 0000000000..5f3e142d2a --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.method.iteration.scope @@ -0,0 +1,12 @@ +public class MyClass { + public void foo(String name, int age) {} +} +--- + +[Range] = 1:20-1:40 + >--------------------< +1| public void foo(String name, int age) {} + +[Domain] = 1:4-1:44 + >----------------------------------------< +1| public void foo(String name, int age) {} diff --git a/data/fixtures/scopes/java/argument.formal.method.scope b/data/fixtures/scopes/java/argument.formal.method.scope new file mode 100644 index 0000000000..a67504d3d3 --- /dev/null +++ b/data/fixtures/scopes/java/argument.formal.method.scope @@ -0,0 +1,35 @@ +public class MyClass { + public void foo(String name, int age) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:20-1:31 + >-----------< +1| public void foo(String name, int age) {} + +[#1 Removal] = 1:20-1:33 + >-------------< +1| public void foo(String name, int age) {} + +[#1 Trailing delimiter] = 1:31-1:33 + >--< +1| public void foo(String name, int age) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:33-1:40 + >-------< +1| public void foo(String name, int age) {} + +[#2 Removal] = 1:31-1:40 + >---------< +1| public void foo(String name, int age) {} + +[#2 Leading delimiter] = 1:31-1:33 + >--< +1| public void foo(String name, int age) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/java/branch.switchCase.iteration.scope b/data/fixtures/scopes/java/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..737728229c --- /dev/null +++ b/data/fixtures/scopes/java/branch.switchCase.iteration.scope @@ -0,0 +1,33 @@ +switch (value) { + case 1: + break; + case 2: + break; + default: + break; +} +--- + +[Range] = 0:16-7:0 + > +0| switch (value) { +1| case 1: +2| break; +3| case 2: +4| break; +5| default: +6| break; +7| } + < + +[Domain] = 0:0-7:1 + >---------------- +0| switch (value) { +1| case 1: +2| break; +3| case 2: +4| break; +5| default: +6| break; +7| } + -< diff --git a/data/fixtures/scopes/java/branch.switchCase.scope b/data/fixtures/scopes/java/branch.switchCase.scope new file mode 100644 index 0000000000..66ac2695d4 --- /dev/null +++ b/data/fixtures/scopes/java/branch.switchCase.scope @@ -0,0 +1,71 @@ +switch (value) { + case 1: + break; + case 2: + break; + default: + break; +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-2:14 + >------- +1| case 1: +2| break; + --------------< + +[#1 Removal] = 1:0-3:0 + >----------- +1| case 1: +2| break; +3| case 2: + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| case 1: + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 3:4-4:14 + >------- +3| case 2: +4| break; + --------------< + +[#2 Removal] = 3:0-5:0 + >----------- +3| case 2: +4| break; +5| default: + < + +[#2 Leading delimiter] = 3:0-3:4 + >----< +3| case 2: + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 5:4-6:14 + >-------- +5| default: +6| break; + --------------< + +[#3 Removal] = 5:0-7:0 + >------------ +5| default: +6| break; +7| } + < + +[#3 Leading delimiter] = 5:0-5:4 + >----< +5| default: + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/branch.ternary.scope b/data/fixtures/scopes/java/branch.ternary.scope new file mode 100644 index 0000000000..75fa5f5e2b --- /dev/null +++ b/data/fixtures/scopes/java/branch.ternary.scope @@ -0,0 +1,37 @@ +value != null ? value : -1; +--- + +[#1 Content] = +[#1 Domain] = 0:16-0:21 + >-----< +0| value != null ? value : -1; + +[#1 Removal] = 0:16-0:22 + >------< +0| value != null ? value : -1; + +[#1 Leading delimiter] = 0:15-0:16 + >-< +0| value != null ? value : -1; + +[#1 Trailing delimiter] = 0:21-0:22 + >-< +0| value != null ? value : -1; + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:24-0:26 + >--< +0| value != null ? value : -1; + +[#2 Removal] = 0:23-0:26 + >---< +0| value != null ? value : -1; + +[#2 Leading delimiter] = 0:23-0:24 + >-< +0| value != null ? value : -1; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/class.scope b/data/fixtures/scopes/java/class.scope new file mode 100644 index 0000000000..eab5a96bbd --- /dev/null +++ b/data/fixtures/scopes/java/class.scope @@ -0,0 +1,10 @@ +public class MyClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/java/className.scope b/data/fixtures/scopes/java/className.scope new file mode 100644 index 0000000000..dfc56cf188 --- /dev/null +++ b/data/fixtures/scopes/java/className.scope @@ -0,0 +1,24 @@ +public class MyClass { } +--- + +[Content] = 0:13-0:20 + >-------< +0| public class MyClass { } + +[Removal] = 0:13-0:21 + >--------< +0| public class MyClass { } + +[Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { } + +[Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { } + +[Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/comment.block.scope b/data/fixtures/scopes/java/comment.block.scope new file mode 100644 index 0000000000..7c4611e225 --- /dev/null +++ b/data/fixtures/scopes/java/comment.block.scope @@ -0,0 +1,10 @@ +/* Hello */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| /* Hello */ + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/comment.line.scope b/data/fixtures/scopes/java/comment.line.scope new file mode 100644 index 0000000000..576f62c186 --- /dev/null +++ b/data/fixtures/scopes/java/comment.line.scope @@ -0,0 +1,10 @@ +// Hello +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| // Hello + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/condition.doWhile.scope b/data/fixtures/scopes/java/condition.doWhile.scope new file mode 100644 index 0000000000..a08fbe233d --- /dev/null +++ b/data/fixtures/scopes/java/condition.doWhile.scope @@ -0,0 +1,13 @@ +do { } while(value != null); +--- + +[Content] = +[Removal] = 0:13-0:26 + >-------------< +0| do { } while(value != null); + +[Domain] = 0:0-0:28 + >----------------------------< +0| do { } while(value != null); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/condition.for.scope b/data/fixtures/scopes/java/condition.for.scope new file mode 100644 index 0000000000..12ebd6c6c0 --- /dev/null +++ b/data/fixtures/scopes/java/condition.for.scope @@ -0,0 +1,20 @@ +for (int i = 0; i < value.length; ++i) { } +--- + +[Content] = 0:16-0:32 + >----------------< +0| for (int i = 0; i < value.length; ++i) { } + +[Removal] = 0:15-0:32 + >-----------------< +0| for (int i = 0; i < value.length; ++i) { } + +[Leading delimiter] = 0:15-0:16 + >-< +0| for (int i = 0; i < value.length; ++i) { } + +[Domain] = 0:0-0:42 + >------------------------------------------< +0| for (int i = 0; i < value.length; ++i) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/condition.if.scope b/data/fixtures/scopes/java/condition.if.scope new file mode 100644 index 0000000000..b1ee077a52 --- /dev/null +++ b/data/fixtures/scopes/java/condition.if.scope @@ -0,0 +1,13 @@ +if (value != null) { } +--- + +[Content] = +[Removal] = 0:4-0:17 + >-------------< +0| if (value != null) { } + +[Domain] = 0:0-0:22 + >----------------------< +0| if (value != null) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/condition.switchCase.iteration.scope b/data/fixtures/scopes/java/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..737728229c --- /dev/null +++ b/data/fixtures/scopes/java/condition.switchCase.iteration.scope @@ -0,0 +1,33 @@ +switch (value) { + case 1: + break; + case 2: + break; + default: + break; +} +--- + +[Range] = 0:16-7:0 + > +0| switch (value) { +1| case 1: +2| break; +3| case 2: +4| break; +5| default: +6| break; +7| } + < + +[Domain] = 0:0-7:1 + >---------------- +0| switch (value) { +1| case 1: +2| break; +3| case 2: +4| break; +5| default: +6| break; +7| } + -< diff --git a/data/fixtures/scopes/java/condition.switchCase.scope b/data/fixtures/scopes/java/condition.switchCase.scope new file mode 100644 index 0000000000..cc709a517b --- /dev/null +++ b/data/fixtures/scopes/java/condition.switchCase.scope @@ -0,0 +1,50 @@ +switch (value) { + case 1: + break; + case 2: + break; + default: + break; +} +--- + +[#1 Content] = 1:9-1:10 + >-< +1| case 1: + +[#1 Removal] = 1:8-1:10 + >--< +1| case 1: + +[#1 Leading delimiter] = 1:8-1:9 + >-< +1| case 1: + +[#1 Domain] = 1:4-2:14 + >------- +1| case 1: +2| break; + --------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 3:9-3:10 + >-< +3| case 2: + +[#2 Removal] = 3:8-3:10 + >--< +3| case 2: + +[#2 Leading delimiter] = 3:8-3:9 + >-< +3| case 2: + +[#2 Domain] = 3:4-4:14 + >------- +3| case 2: +4| break; + --------------< + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/condition.ternary.scope b/data/fixtures/scopes/java/condition.ternary.scope new file mode 100644 index 0000000000..2d7ade10ae --- /dev/null +++ b/data/fixtures/scopes/java/condition.ternary.scope @@ -0,0 +1,20 @@ +value != null ? value : -1; +--- + +[Content] = 0:0-0:13 + >-------------< +0| value != null ? value : -1; + +[Removal] = 0:0-0:14 + >--------------< +0| value != null ? value : -1; + +[Trailing delimiter] = 0:13-0:14 + >-< +0| value != null ? value : -1; + +[Domain] = 0:0-0:26 + >--------------------------< +0| value != null ? value : -1; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/condition.while.scope b/data/fixtures/scopes/java/condition.while.scope new file mode 100644 index 0000000000..baedea2418 --- /dev/null +++ b/data/fixtures/scopes/java/condition.while.scope @@ -0,0 +1,13 @@ +while(value != null) { } +--- + +[Content] = +[Removal] = 0:6-0:19 + >-------------< +0| while(value != null) { } + +[Domain] = 0:0-0:24 + >------------------------< +0| while(value != null) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionCall.constructor.scope b/data/fixtures/scopes/java/functionCall.constructor.scope new file mode 100644 index 0000000000..1792bc1720 --- /dev/null +++ b/data/fixtures/scopes/java/functionCall.constructor.scope @@ -0,0 +1,10 @@ +new Foo(123, 456); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| new Foo(123, 456); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionCall.scope b/data/fixtures/scopes/java/functionCall.scope new file mode 100644 index 0000000000..0d549d2308 --- /dev/null +++ b/data/fixtures/scopes/java/functionCall.scope @@ -0,0 +1,10 @@ +foo(123, 456); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| foo(123, 456); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionCallee.constructor.scope b/data/fixtures/scopes/java/functionCallee.constructor.scope new file mode 100644 index 0000000000..e23818aa3d --- /dev/null +++ b/data/fixtures/scopes/java/functionCallee.constructor.scope @@ -0,0 +1,13 @@ +new Foo(); +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| new Foo(); + +[Domain] = 0:0-0:10 + >----------< +0| new Foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionCallee.scope b/data/fixtures/scopes/java/functionCallee.scope new file mode 100644 index 0000000000..0dbddcd146 --- /dev/null +++ b/data/fixtures/scopes/java/functionCallee.scope @@ -0,0 +1,13 @@ +foo(); +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| foo(); + +[Domain] = 0:0-0:6 + >------< +0| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionName.constructor.scope b/data/fixtures/scopes/java/functionName.constructor.scope new file mode 100644 index 0000000000..160e54fd14 --- /dev/null +++ b/data/fixtures/scopes/java/functionName.constructor.scope @@ -0,0 +1,19 @@ +public class MyClass { + public MyClass() { } +} +--- + +[Content] = +[Removal] = 1:11-1:18 + >-------< +1| public MyClass() { } + +[Leading delimiter] = 1:10-1:11 + >-< +1| public MyClass() { } + +[Domain] = 1:4-1:24 + >--------------------< +1| public MyClass() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/functionName.method.scope b/data/fixtures/scopes/java/functionName.method.scope new file mode 100644 index 0000000000..c2687ad6c3 --- /dev/null +++ b/data/fixtures/scopes/java/functionName.method.scope @@ -0,0 +1,19 @@ +public class MyClass { + public void foo() { } +} +--- + +[Content] = +[Removal] = 1:16-1:19 + >---< +1| public void foo() { } + +[Leading delimiter] = 1:15-1:16 + >-< +1| public void foo() { } + +[Domain] = 1:4-1:25 + >---------------------< +1| public void foo() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/ifStatement.scope b/data/fixtures/scopes/java/ifStatement.scope new file mode 100644 index 0000000000..386e130326 --- /dev/null +++ b/data/fixtures/scopes/java/ifStatement.scope @@ -0,0 +1,10 @@ +if (value != null) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:22 + >----------------------< +0| if (value != null) { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/list.scope b/data/fixtures/scopes/java/list.scope new file mode 100644 index 0000000000..b69f66f00c --- /dev/null +++ b/data/fixtures/scopes/java/list.scope @@ -0,0 +1,10 @@ +new int[]{1, 2, 3}; +--- + +[Content] = +[Removal] = +[Domain] = 0:9-0:18 + >---------< +0| new int[]{1, 2, 3}; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.argument.formal.method.scope b/data/fixtures/scopes/java/name.argument.formal.method.scope new file mode 100644 index 0000000000..512229ce6e --- /dev/null +++ b/data/fixtures/scopes/java/name.argument.formal.method.scope @@ -0,0 +1,83 @@ +public class MyClass { + public void foo(String name, int value) { } +} +--- + +[#1 Content] = 0:13-0:20 + >-------< +0| public class MyClass { + +[#1 Removal] = 0:13-0:21 + >--------< +0| public class MyClass { + +[#1 Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { + +[#1 Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { + +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public void foo(String name, int value) { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:16-1:19 + >---< +1| public void foo(String name, int value) { } + +[#2 Leading delimiter] = 1:15-1:16 + >-< +1| public void foo(String name, int value) { } + +[#2 Domain] = 1:4-1:47 + >-------------------------------------------< +1| public void foo(String name, int value) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:27-1:31 + >----< +1| public void foo(String name, int value) { } + +[#3 Removal] = 1:26-1:31 + >-----< +1| public void foo(String name, int value) { } + +[#3 Leading delimiter] = 1:26-1:27 + >-< +1| public void foo(String name, int value) { } + +[#3 Domain] = 1:20-1:31 + >-----------< +1| public void foo(String name, int value) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:37-1:42 + >-----< +1| public void foo(String name, int value) { } + +[#4 Removal] = 1:36-1:42 + >------< +1| public void foo(String name, int value) { } + +[#4 Leading delimiter] = 1:36-1:37 + >-< +1| public void foo(String name, int value) { } + +[#4 Domain] = 1:33-1:42 + >---------< +1| public void foo(String name, int value) { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.assignment.scope b/data/fixtures/scopes/java/name.assignment.scope new file mode 100644 index 0000000000..f18bb86183 --- /dev/null +++ b/data/fixtures/scopes/java/name.assignment.scope @@ -0,0 +1,20 @@ +value = 123; +--- + +[Content] = 0:0-0:5 + >-----< +0| value = 123; + +[Removal] = 0:0-0:8 + >--------< +0| value = 123; + +[Trailing delimiter] = 0:5-0:8 + >---< +0| value = 123; + +[Domain] = 0:0-0:12 + >------------< +0| value = 123; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.class.scope b/data/fixtures/scopes/java/name.class.scope new file mode 100644 index 0000000000..dfc56cf188 --- /dev/null +++ b/data/fixtures/scopes/java/name.class.scope @@ -0,0 +1,24 @@ +public class MyClass { } +--- + +[Content] = 0:13-0:20 + >-------< +0| public class MyClass { } + +[Removal] = 0:13-0:21 + >--------< +0| public class MyClass { } + +[Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { } + +[Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { } + +[Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.constructor.scope b/data/fixtures/scopes/java/name.constructor.scope new file mode 100644 index 0000000000..9b6a51c2f9 --- /dev/null +++ b/data/fixtures/scopes/java/name.constructor.scope @@ -0,0 +1,45 @@ +public class MyClass { + public MyClass() { } +} +--- + +[#1 Content] = 0:13-0:20 + >-------< +0| public class MyClass { + +[#1 Removal] = 0:13-0:21 + >--------< +0| public class MyClass { + +[#1 Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { + +[#1 Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { + +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public MyClass() { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:11-1:18 + >-------< +1| public MyClass() { } + +[#2 Leading delimiter] = 1:10-1:11 + >-< +1| public MyClass() { } + +[#2 Domain] = 1:4-1:24 + >--------------------< +1| public MyClass() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.field.scope b/data/fixtures/scopes/java/name.field.scope new file mode 100644 index 0000000000..bd3fdd13ad --- /dev/null +++ b/data/fixtures/scopes/java/name.field.scope @@ -0,0 +1,48 @@ +public class MyClass { + private int value; +} +--- + +[#1 Content] = 0:13-0:20 + >-------< +0| public class MyClass { + +[#1 Removal] = 0:13-0:21 + >--------< +0| public class MyClass { + +[#1 Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { + +[#1 Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { + +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| private int value; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:16-1:21 + >-----< +1| private int value; + +[#2 Removal] = 1:15-1:21 + >------< +1| private int value; + +[#2 Leading delimiter] = 1:15-1:16 + >-< +1| private int value; + +[#2 Domain] = 1:4-1:22 + >------------------< +1| private int value; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.method.scope b/data/fixtures/scopes/java/name.method.scope new file mode 100644 index 0000000000..e31d1facd0 --- /dev/null +++ b/data/fixtures/scopes/java/name.method.scope @@ -0,0 +1,45 @@ +public class MyClass { + public void foo() { } +} +--- + +[#1 Content] = 0:13-0:20 + >-------< +0| public class MyClass { + +[#1 Removal] = 0:13-0:21 + >--------< +0| public class MyClass { + +[#1 Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { + +[#1 Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { + +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public void foo() { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:16-1:19 + >---< +1| public void foo() { } + +[#2 Leading delimiter] = 1:15-1:16 + >-< +1| public void foo() { } + +[#2 Domain] = 1:4-1:25 + >---------------------< +1| public void foo() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.variable.scope b/data/fixtures/scopes/java/name.variable.scope new file mode 100644 index 0000000000..6c908fcf08 --- /dev/null +++ b/data/fixtures/scopes/java/name.variable.scope @@ -0,0 +1,20 @@ +int value = 123; +--- + +[Content] = 0:4-0:9 + >-----< +0| int value = 123; + +[Removal] = 0:4-0:12 + >--------< +0| int value = 123; + +[Trailing delimiter] = 0:9-0:12 + >---< +0| int value = 123; + +[Domain] = 0:0-0:16 + >----------------< +0| int value = 123; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/namedFunction.method.scope b/data/fixtures/scopes/java/namedFunction.method.scope new file mode 100644 index 0000000000..cd7412a16f --- /dev/null +++ b/data/fixtures/scopes/java/namedFunction.method.scope @@ -0,0 +1,21 @@ +public class MyClass { + public void foo() { } +} +--- + +[Content] = +[Domain] = 1:4-1:25 + >---------------------< +1| public void foo() { } + +[Removal] = 1:0-2:0 + >------------------------- +1| public void foo() { } +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| public void foo() { } + +[Insertion delimiter] = "\n\n" diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 6f9bda944a..d37614fbb5 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -1,7 +1,7 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, notApplicable } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const javaScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, @@ -29,9 +29,159 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "branch.try": supported, "branch.try.iteration": supported, - element: notApplicable, - tags: notApplicable, - attribute: notApplicable, + anonymousFunction: supported, + "argument.actual.constructor": supported, + "argument.actual.constructor.iteration": supported, + "argument.actual.method": supported, + "argument.actual.method.iteration": supported, + "argument.formal.constructor": supported, + "argument.formal.constructor.iteration": supported, + "argument.formal.method": supported, + "argument.formal.method.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + class: supported, + className: supported, + "comment.block": supported, + "comment.line": supported, + "condition.doWhile": supported, + "condition.for": supported, + "condition.if": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, + "condition.ternary": supported, + "condition.while": supported, + functionCall: supported, + "functionCall.constructor": supported, + functionCallee: supported, + "functionCallee.constructor": supported, + functionName: supported, + "functionName.constructor": supported, + "functionName.iteration.block": supported, + "functionName.iteration.document": supported, + "functionName.method": supported, + "functionName.method.iteration.class": supported, + ifStatement: supported, + + "key.mapPair": supported, + "key.mapPair.iteration": supported, + list: supported, + map: supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.assignment": supported, + "name.class": supported, + "name.constructor": supported, + "name.field": supported, + "name.iteration.block": supported, + "name.iteration.document": supported, + "name.method": supported, + "name.variable": supported, + "name.variable.pattern": supported, + namedFunction: supported, + "namedFunction.constructor": supported, + "namedFunction.iteration.block": supported, + "namedFunction.iteration.document": supported, + "namedFunction.method": supported, + "namedFunction.method.iteration.class": supported, + pairDelimiter: supported, + statement: supported, + "statement.class": supported, + "statement.iteration.block": supported, + "statement.iteration.document": supported, + "string.multiLine": supported, + "string.singleLine": supported, + switchStatementSubject: supported, + "textFragment.comment.block": supported, + "textFragment.comment.line": supported, + "textFragment.string.multiLine": supported, + "textFragment.string.singleLine": supported, + "type.alias": supported, + "type.argument.formal": supported, + "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, + "type.argument.formal.iteration": supported, + "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, + "type.cast": supported, + "type.class": supported, + "type.enum": supported, + "type.interface": supported, + "type.return": supported, + "type.variable": supported, + "value.argument.actual": supported, + "value.argument.actual.iteration": supported, + "value.argument.formal": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, + "value.assignment": supported, + "value.field": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, + "value.resource": supported, + "value.resource.iteration": supported, + "value.return": supported, + "value.return.lambda": supported, + "value.typeAlias": supported, + "value.variable.pattern": supported, + "value.yield": supported, + + // Unsupported + + "branch.loop": unsupported, + "class.iteration.block": unsupported, + "class.iteration.document": unsupported, + "className.iteration.block": unsupported, + "className.iteration.document": unsupported, + fieldAccess: unsupported, + + "name.resource": unsupported, + "name.resource.iteration": unsupported, + + "interior.class": unsupported, + "interior.element": unsupported, + "interior.function": unsupported, + "interior.if": unsupported, + "interior.lambda": unsupported, + "interior.loop": unsupported, + "interior.resource": unsupported, + "interior.switchCase": unsupported, + "interior.ternary": unsupported, + "interior.try": unsupported, + + // Not Applicable + + "name.assignment.pattern": notApplicable, + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.iteration": notApplicable, + "name.function": notApplicable, + + "value.variable": notApplicable, + + regularExpression: notApplicable, + + environment: notApplicable, + "interior.cell": notApplicable, + "interior.command": notApplicable, "key.attribute": notApplicable, + notebookCell: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + section: notApplicable, + "textFragment.element": notApplicable, "value.attribute": notApplicable, + attribute: notApplicable, + command: notApplicable, + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, }; diff --git a/queries/java.scm b/queries/java.scm index 10e1e28f50..94ff762d24 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -124,7 +124,14 @@ ) ) @condition.domain -(switch_expression) @branch.iteration @condition.iteration +(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 ;;!! if () {} ;;! ^^^^^^^^ From 6941e583248c5536feb5715e729c09ceab9640d8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 12 Feb 2025 08:56:54 +0100 Subject: [PATCH 2/6] More tests --- ...rgument.formal.constructor.iteration.scope | 12 ++ .../name.argument.formal.constructor.scope | 83 +++++++++++++ ...ame.argument.formal.method.iteration.scope | 12 ++ .../common/src/scopeSupportFacets/java.ts | 111 ++++++++++-------- queries/java.scm | 16 ++- 5 files changed, 182 insertions(+), 52 deletions(-) create mode 100644 data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/java/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/java/name.argument.formal.method.iteration.scope diff --git a/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..15f2dc4312 --- /dev/null +++ b/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope @@ -0,0 +1,12 @@ +public class MyClass { + public MyClass(String name, int value) { } +} +--- + +[Range] = 1:19-1:41 + >----------------------< +1| public MyClass(String name, int value) { } + +[Domain] = 1:18-1:42 + >------------------------< +1| public MyClass(String name, int value) { } diff --git a/data/fixtures/scopes/java/name.argument.formal.constructor.scope b/data/fixtures/scopes/java/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..50c40d9133 --- /dev/null +++ b/data/fixtures/scopes/java/name.argument.formal.constructor.scope @@ -0,0 +1,83 @@ +public class MyClass { + public MyClass(String name, int value) { } +} +--- + +[#1 Content] = 0:13-0:20 + >-------< +0| public class MyClass { + +[#1 Removal] = 0:13-0:21 + >--------< +0| public class MyClass { + +[#1 Leading delimiter] = 0:12-0:13 + >-< +0| public class MyClass { + +[#1 Trailing delimiter] = 0:20-0:21 + >-< +0| public class MyClass { + +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public MyClass(String name, int value) { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:11-1:18 + >-------< +1| public MyClass(String name, int value) { } + +[#2 Leading delimiter] = 1:10-1:11 + >-< +1| public MyClass(String name, int value) { } + +[#2 Domain] = 1:4-1:46 + >------------------------------------------< +1| public MyClass(String name, int value) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:26-1:30 + >----< +1| public MyClass(String name, int value) { } + +[#3 Removal] = 1:25-1:30 + >-----< +1| public MyClass(String name, int value) { } + +[#3 Leading delimiter] = 1:25-1:26 + >-< +1| public MyClass(String name, int value) { } + +[#3 Domain] = 1:19-1:30 + >-----------< +1| public MyClass(String name, int value) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:36-1:41 + >-----< +1| public MyClass(String name, int value) { } + +[#4 Removal] = 1:35-1:41 + >------< +1| public MyClass(String name, int value) { } + +[#4 Leading delimiter] = 1:35-1:36 + >-< +1| public MyClass(String name, int value) { } + +[#4 Domain] = 1:32-1:41 + >---------< +1| public MyClass(String name, int value) { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..073b8b3ae0 --- /dev/null +++ b/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope @@ -0,0 +1,12 @@ +public class MyClass { + public void foo(String name, int value) { } +} +--- + +[Range] = 1:20-1:42 + >----------------------< +1| public void foo(String name, int value) { } + +[Domain] = 1:19-1:43 + >------------------------< +1| public void foo(String name, int value) { } diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index d37614fbb5..6468baed63 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -5,21 +5,24 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const javaScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, + anonymousFunction: supported, + list: supported, + map: supported, + pairDelimiter: supported, + switchStatementSubject: supported, - "name.foreach": supported, - - "value.foreach": supported, - - "type.foreach": supported, - "type.field": supported, - "type.field.iteration": supported, - "type.typeArgument": supported, - "type.typeArgument.iteration": supported, - - "argument.formal": supported, - "argument.formal.iteration": supported, "argument.actual": supported, "argument.actual.iteration": supported, + "argument.actual.constructor": supported, + "argument.actual.constructor.iteration": supported, + "argument.actual.method": supported, + "argument.actual.method.iteration": supported, + "argument.formal": supported, + "argument.formal.iteration": supported, + "argument.formal.constructor": supported, + "argument.formal.constructor.iteration": supported, + "argument.formal.method": supported, + "argument.formal.method.iteration": supported, "collectionItem.unenclosed": supported, "collectionItem.unenclosed.iteration": supported, @@ -29,22 +32,16 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "branch.try": supported, "branch.try.iteration": supported, - anonymousFunction: supported, - "argument.actual.constructor": supported, - "argument.actual.constructor.iteration": supported, - "argument.actual.method": supported, - "argument.actual.method.iteration": supported, - "argument.formal.constructor": supported, - "argument.formal.constructor.iteration": supported, - "argument.formal.method": supported, - "argument.formal.method.iteration": supported, "branch.switchCase": supported, "branch.switchCase.iteration": supported, "branch.ternary": supported, + class: supported, className: supported, + "comment.block": supported, "comment.line": supported, + "condition.doWhile": supported, "condition.for": supported, "condition.if": supported, @@ -52,22 +49,18 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "condition.switchCase.iteration": supported, "condition.ternary": supported, "condition.while": supported, + functionCall: supported, "functionCall.constructor": supported, functionCallee: supported, "functionCallee.constructor": supported, - functionName: supported, + "functionName.constructor": supported, - "functionName.iteration.block": supported, - "functionName.iteration.document": supported, "functionName.method": supported, - "functionName.method.iteration.class": supported, - ifStatement: supported, "key.mapPair": supported, "key.mapPair.iteration": supported, - list: supported, - map: supported, + "name.argument.formal.constructor": supported, "name.argument.formal.constructor.iteration": supported, "name.argument.formal.method": supported, @@ -76,29 +69,34 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.class": supported, "name.constructor": supported, "name.field": supported, + "name.foreach": supported, "name.iteration.block": supported, "name.iteration.document": supported, "name.method": supported, "name.variable": supported, "name.variable.pattern": supported, - namedFunction: supported, "namedFunction.constructor": supported, "namedFunction.iteration.block": supported, "namedFunction.iteration.document": supported, "namedFunction.method": supported, - "namedFunction.method.iteration.class": supported, - pairDelimiter: supported, + + ifStatement: supported, statement: supported, "statement.class": supported, "statement.iteration.block": supported, "statement.iteration.document": supported, + "string.multiLine": supported, "string.singleLine": supported, - switchStatementSubject: supported, + "textFragment.comment.block": supported, "textFragment.comment.line": supported, "textFragment.string.multiLine": supported, "textFragment.string.singleLine": supported, + + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, + "type.alias": supported, "type.argument.formal": supported, "type.argument.formal.constructor": supported, @@ -109,18 +107,19 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.cast": supported, "type.class": supported, "type.enum": supported, + "type.foreach": supported, + "type.field": supported, + "type.field.iteration": supported, "type.interface": supported, "type.return": supported, "type.variable": supported, - "value.argument.actual": supported, - "value.argument.actual.iteration": supported, - "value.argument.formal": supported, + "value.argument.formal.constructor": supported, "value.argument.formal.constructor.iteration": supported, - "value.argument.formal.iteration": supported, "value.argument.formal.method": supported, "value.argument.formal.method.iteration": supported, "value.assignment": supported, + "value.foreach": supported, "value.field": supported, "value.mapPair": supported, "value.mapPair.iteration": supported, @@ -134,16 +133,20 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { // Unsupported - "branch.loop": unsupported, "class.iteration.block": unsupported, "class.iteration.document": unsupported, "className.iteration.block": unsupported, "className.iteration.document": unsupported, - fieldAccess: unsupported, "name.resource": unsupported, "name.resource.iteration": unsupported, + "namedFunction.method.iteration.class": unsupported, + + "functionName.iteration.block": unsupported, + "functionName.iteration.document": unsupported, + "functionName.method.iteration.class": unsupported, + "interior.class": unsupported, "interior.element": unsupported, "interior.function": unsupported, @@ -155,6 +158,9 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "interior.ternary": unsupported, "interior.try": unsupported, + "branch.loop": unsupported, + fieldAccess: unsupported, + // Not Applicable "name.assignment.pattern": notApplicable, @@ -165,23 +171,32 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.function": notApplicable, "value.variable": notApplicable, + "value.attribute": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.iteration": supported, - regularExpression: notApplicable, + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "textFragment.element": notApplicable, + + namedFunction: notApplicable, + functionName: notApplicable, + + regularExpression: notApplicable, environment: notApplicable, "interior.cell": notApplicable, "interior.command": notApplicable, "key.attribute": notApplicable, notebookCell: notApplicable, - "section.iteration.document": notApplicable, - "section.iteration.parent": notApplicable, - section: notApplicable, - "textFragment.element": notApplicable, - "value.attribute": notApplicable, attribute: notApplicable, command: notApplicable, - element: notApplicable, - tags: notApplicable, - startTag: notApplicable, - endTag: notApplicable, }; diff --git a/queries/java.scm b/queries/java.scm index 94ff762d24..2211f5b2d3 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -230,11 +230,19 @@ ;;!! void myFunk(int value) {} ;;! ^^^^^ ;;! ------------------------- +(formal_parameter + (identifier) @name +) @_.domain + +;;!! void myFunk(int value) {} +;;! ^^^^^^^^^ (formal_parameters - (formal_parameter - (identifier) @name - ) @_.domain -) @_.iteration + . + "(" @name.iteration.start.endOf + + ")" @name.iteration.end.startOf + . +) @name.iteration.domain ;;!! Map ;;! ^^^^^^^ ^^^^^^ From 99ba3561d9436bfadf2dd5db15009c27ad702383 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 12 Feb 2025 09:26:32 +0100 Subject: [PATCH 3/6] More tests --- .../java/namedFunction.constructor.scope | 21 ++++++ .../scopes/java/statement.class.scope | 10 +++ data/fixtures/scopes/java/statement.scope | 10 +++ .../scopes/java/string.singleLine.scope | 10 +++ .../scopes/java/switchStatementSubject.scope | 13 ++++ .../java/textFragment.comment.block.scope | 10 +++ .../java/textFragment.comment.line.scope | 10 +++ .../java/textFragment.string.singleLine.scope | 10 +++ .../type.argument.formal.constructor.scope | 26 ++++++++ .../java/type.argument.formal.method.scope | 49 ++++++++++++++ data/fixtures/scopes/java/type.return.scope | 31 +++++++++ data/fixtures/scopes/java/type.variable.scope | 20 ++++++ .../fixtures/scopes/java/type.variable2.scope | 20 ++++++ .../common/src/scopeSupportFacets/java.ts | 65 ++++++++++--------- queries/java.scm | 5 +- 15 files changed, 278 insertions(+), 32 deletions(-) create mode 100644 data/fixtures/scopes/java/namedFunction.constructor.scope create mode 100644 data/fixtures/scopes/java/statement.class.scope create mode 100644 data/fixtures/scopes/java/statement.scope create mode 100644 data/fixtures/scopes/java/string.singleLine.scope create mode 100644 data/fixtures/scopes/java/switchStatementSubject.scope create mode 100644 data/fixtures/scopes/java/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/java/textFragment.comment.line.scope create mode 100644 data/fixtures/scopes/java/textFragment.string.singleLine.scope create mode 100644 data/fixtures/scopes/java/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/java/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/java/type.return.scope create mode 100644 data/fixtures/scopes/java/type.variable.scope create mode 100644 data/fixtures/scopes/java/type.variable2.scope diff --git a/data/fixtures/scopes/java/namedFunction.constructor.scope b/data/fixtures/scopes/java/namedFunction.constructor.scope new file mode 100644 index 0000000000..e683eae9c7 --- /dev/null +++ b/data/fixtures/scopes/java/namedFunction.constructor.scope @@ -0,0 +1,21 @@ +public class MyClass { + public MyClass() { } +} +--- + +[Content] = +[Domain] = 1:4-1:24 + >--------------------< +1| public MyClass() { } + +[Removal] = 1:0-2:0 + >------------------------ +1| public MyClass() { } +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| public MyClass() { } + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/java/statement.class.scope b/data/fixtures/scopes/java/statement.class.scope new file mode 100644 index 0000000000..5153070300 --- /dev/null +++ b/data/fixtures/scopes/java/statement.class.scope @@ -0,0 +1,10 @@ +public class MyClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/statement.scope b/data/fixtures/scopes/java/statement.scope new file mode 100644 index 0000000000..f64174b953 --- /dev/null +++ b/data/fixtures/scopes/java/statement.scope @@ -0,0 +1,10 @@ +if (true) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/string.singleLine.scope b/data/fixtures/scopes/java/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/java/string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/switchStatementSubject.scope b/data/fixtures/scopes/java/switchStatementSubject.scope new file mode 100644 index 0000000000..d8df9f3d58 --- /dev/null +++ b/data/fixtures/scopes/java/switchStatementSubject.scope @@ -0,0 +1,13 @@ +switch (value) { } +--- + +[Content] = +[Removal] = 0:8-0:13 + >-----< +0| switch (value) { } + +[Domain] = 0:0-0:18 + >------------------< +0| switch (value) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/textFragment.comment.block.scope b/data/fixtures/scopes/java/textFragment.comment.block.scope new file mode 100644 index 0000000000..af33f95d00 --- /dev/null +++ b/data/fixtures/scopes/java/textFragment.comment.block.scope @@ -0,0 +1,10 @@ +/* Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/textFragment.comment.line.scope b/data/fixtures/scopes/java/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/data/fixtures/scopes/java/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/textFragment.string.singleLine.scope b/data/fixtures/scopes/java/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..85dcf5fa7f --- /dev/null +++ b/data/fixtures/scopes/java/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.argument.formal.constructor.scope b/data/fixtures/scopes/java/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..8377e0d303 --- /dev/null +++ b/data/fixtures/scopes/java/type.argument.formal.constructor.scope @@ -0,0 +1,26 @@ +public class MyClass { + public MyClass(final int value) { } +} +--- + +[Content] = 1:25-1:28 + >---< +1| public MyClass(final int value) { } + +[Removal] = 1:25-1:29 + >----< +1| public MyClass(final int value) { } + +[Leading delimiter] = 1:24-1:25 + >-< +1| public MyClass(final int value) { } + +[Trailing delimiter] = 1:28-1:29 + >-< +1| public MyClass(final int value) { } + +[Domain] = 1:19-1:34 + >---------------< +1| public MyClass(final int value) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.argument.formal.method.scope b/data/fixtures/scopes/java/type.argument.formal.method.scope new file mode 100644 index 0000000000..c4bfe46cc6 --- /dev/null +++ b/data/fixtures/scopes/java/type.argument.formal.method.scope @@ -0,0 +1,49 @@ +public class MyClass { + public void foo(final int value) { } +} +--- + +[#1 Content] = 1:11-1:15 + >----< +1| public void foo(final int value) { } + +[#1 Removal] = 1:11-1:16 + >-----< +1| public void foo(final int value) { } + +[#1 Leading delimiter] = 1:10-1:11 + >-< +1| public void foo(final int value) { } + +[#1 Trailing delimiter] = 1:15-1:16 + >-< +1| public void foo(final int value) { } + +[#1 Domain] = 1:4-1:40 + >------------------------------------< +1| public void foo(final int value) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:26-1:29 + >---< +1| public void foo(final int value) { } + +[#2 Removal] = 1:26-1:30 + >----< +1| public void foo(final int value) { } + +[#2 Leading delimiter] = 1:25-1:26 + >-< +1| public void foo(final int value) { } + +[#2 Trailing delimiter] = 1:29-1:30 + >-< +1| public void foo(final int value) { } + +[#2 Domain] = 1:20-1:35 + >---------------< +1| public void foo(final int value) { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.return.scope b/data/fixtures/scopes/java/type.return.scope new file mode 100644 index 0000000000..a3df4adec0 --- /dev/null +++ b/data/fixtures/scopes/java/type.return.scope @@ -0,0 +1,31 @@ +public class MyClass { + public int myFunk() { + return 123; + } +} +--- + +[Content] = 1:11-1:14 + >---< +1| public int myFunk() { + +[Removal] = 1:11-1:15 + >----< +1| public int myFunk() { + +[Leading delimiter] = 1:10-1:11 + >-< +1| public int myFunk() { + +[Trailing delimiter] = 1:14-1:15 + >-< +1| public int myFunk() { + +[Domain] = 1:4-3:5 + >--------------------- +1| public int myFunk() { +2| return 123; +3| } + -----< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.variable.scope b/data/fixtures/scopes/java/type.variable.scope new file mode 100644 index 0000000000..7d37d372b7 --- /dev/null +++ b/data/fixtures/scopes/java/type.variable.scope @@ -0,0 +1,20 @@ +int value; +--- + +[Content] = 0:0-0:3 + >---< +0| int value; + +[Removal] = 0:0-0:4 + >----< +0| int value; + +[Trailing delimiter] = 0:3-0:4 + >-< +0| int value; + +[Domain] = 0:0-0:10 + >----------< +0| int value; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.variable2.scope b/data/fixtures/scopes/java/type.variable2.scope new file mode 100644 index 0000000000..a2c664ab43 --- /dev/null +++ b/data/fixtures/scopes/java/type.variable2.scope @@ -0,0 +1,20 @@ +int value = 123; +--- + +[Content] = 0:0-0:3 + >---< +0| int value = 123; + +[Removal] = 0:0-0:4 + >----< +0| int value = 123; + +[Trailing delimiter] = 0:3-0:4 + >-< +0| int value = 123; + +[Domain] = 0:0-0:16 + >----------------< +0| int value = 123; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 6468baed63..303250e659 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -7,8 +7,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, anonymousFunction: supported, list: supported, - map: supported, - pairDelimiter: supported, switchStatementSubject: supported, "argument.actual": supported, @@ -58,9 +56,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "functionName.constructor": supported, "functionName.method": supported, - "key.mapPair": supported, - "key.mapPair.iteration": supported, - "name.argument.formal.constructor": supported, "name.argument.formal.constructor.iteration": supported, "name.argument.formal.method": supported, @@ -71,64 +66,42 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.field": supported, "name.foreach": supported, "name.iteration.block": supported, - "name.iteration.document": supported, "name.method": supported, "name.variable": supported, - "name.variable.pattern": supported, "namedFunction.constructor": supported, - "namedFunction.iteration.block": supported, "namedFunction.iteration.document": supported, "namedFunction.method": supported, ifStatement: supported, statement: supported, "statement.class": supported, - "statement.iteration.block": supported, - "statement.iteration.document": supported, - "string.multiLine": supported, "string.singleLine": supported, "textFragment.comment.block": supported, "textFragment.comment.line": supported, - "textFragment.string.multiLine": supported, "textFragment.string.singleLine": supported, "type.typeArgument": supported, "type.typeArgument.iteration": supported, "type.alias": supported, - "type.argument.formal": supported, "type.argument.formal.constructor": supported, - "type.argument.formal.constructor.iteration": supported, "type.argument.formal.iteration": supported, "type.argument.formal.method": supported, - "type.argument.formal.method.iteration": supported, - "type.cast": supported, - "type.class": supported, - "type.enum": supported, "type.foreach": supported, "type.field": supported, "type.field.iteration": supported, - "type.interface": supported, "type.return": supported, "type.variable": supported, - "value.argument.formal.constructor": supported, - "value.argument.formal.constructor.iteration": supported, - "value.argument.formal.method": supported, - "value.argument.formal.method.iteration": supported, "value.assignment": supported, "value.foreach": supported, "value.field": supported, - "value.mapPair": supported, - "value.mapPair.iteration": supported, - "value.resource": supported, - "value.resource.iteration": supported, "value.return": supported, "value.return.lambda": supported, "value.typeAlias": supported, - "value.variable.pattern": supported, + "value.variable": supported, "value.yield": supported, // Unsupported @@ -138,9 +111,20 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "className.iteration.block": unsupported, "className.iteration.document": unsupported, + "name.iteration.document": unsupported, "name.resource": unsupported, "name.resource.iteration": unsupported, + "type.argument.formal.constructor.iteration": unsupported, + "type.argument.formal.method.iteration": unsupported, + "type.cast": unsupported, + "type.class": unsupported, + "type.enum": unsupported, + "type.interface": unsupported, + + "value.resource": unsupported, + "value.resource.iteration": unsupported, + "namedFunction.method.iteration.class": unsupported, "functionName.iteration.block": unsupported, @@ -158,6 +142,11 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "interior.ternary": unsupported, "interior.try": unsupported, + "statement.iteration.block": unsupported, + "statement.iteration.document": unsupported, + + "string.multiLine": unsupported, + "textFragment.string.multiLine": unsupported, "branch.loop": unsupported, fieldAccess: unsupported, @@ -169,13 +158,25 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal": notApplicable, "name.argument.formal.iteration": notApplicable, "name.function": notApplicable, + "name.variable.pattern": notApplicable, + + "key.mapPair": notApplicable, + "key.mapPair.iteration": notApplicable, - "value.variable": notApplicable, "value.attribute": notApplicable, "value.argument.actual": notApplicable, "value.argument.actual.iteration": notApplicable, "value.argument.formal": notApplicable, - "value.argument.formal.iteration": supported, + "value.argument.formal.iteration": notApplicable, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + "value.variable.pattern": notApplicable, + + "type.argument.formal": notApplicable, section: notApplicable, "section.iteration.document": notApplicable, @@ -188,9 +189,11 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.element": notApplicable, namedFunction: notApplicable, + "namedFunction.iteration.block": notApplicable, + pairDelimiter: notApplicable, functionName: notApplicable, - + map: notApplicable, regularExpression: notApplicable, environment: notApplicable, "interior.cell": notApplicable, diff --git a/queries/java.scm b/queries/java.scm index 2211f5b2d3..0cb9558c0a 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -64,7 +64,10 @@ ;;!! "string" ;;! ^^^^^^^^ -(string_literal) @string @textFragment +( + (string_literal) @string @textFragment + (#character-range! @textFragment 1 -1) +) ;;!! // comment ;;! ^^^^^^^^^^ From 1123b6d74fcb5340993b79f7cf50771e6317bfec Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 12 Feb 2025 09:35:16 +0100 Subject: [PATCH 4/6] More tests --- .../scopes/java/value.assignment.scope | 20 ++++++++++++++++ data/fixtures/scopes/java/value.field.scope | 22 +++++++++++++++++ .../scopes/java/value.return.lambda.scope | 20 ++++++++++++++++ data/fixtures/scopes/java/value.return.scope | 24 +++++++++++++++++++ .../fixtures/scopes/java/value.variable.scope | 20 ++++++++++++++++ .../common/src/scopeSupportFacets/java.ts | 16 ++++++------- 6 files changed, 114 insertions(+), 8 deletions(-) create mode 100644 data/fixtures/scopes/java/value.assignment.scope create mode 100644 data/fixtures/scopes/java/value.field.scope create mode 100644 data/fixtures/scopes/java/value.return.lambda.scope create mode 100644 data/fixtures/scopes/java/value.return.scope create mode 100644 data/fixtures/scopes/java/value.variable.scope diff --git a/data/fixtures/scopes/java/value.assignment.scope b/data/fixtures/scopes/java/value.assignment.scope new file mode 100644 index 0000000000..98eac669f7 --- /dev/null +++ b/data/fixtures/scopes/java/value.assignment.scope @@ -0,0 +1,20 @@ +value = 123; +--- + +[Content] = 0:8-0:11 + >---< +0| value = 123; + +[Removal] = 0:5-0:11 + >------< +0| value = 123; + +[Leading delimiter] = 0:5-0:8 + >---< +0| value = 123; + +[Domain] = 0:0-0:12 + >------------< +0| value = 123; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.field.scope b/data/fixtures/scopes/java/value.field.scope new file mode 100644 index 0000000000..d6449ef022 --- /dev/null +++ b/data/fixtures/scopes/java/value.field.scope @@ -0,0 +1,22 @@ +public class MyClass { + private int value = 123; +} +--- + +[Content] = 1:24-1:27 + >---< +1| private int value = 123; + +[Removal] = 1:21-1:27 + >------< +1| private int value = 123; + +[Leading delimiter] = 1:21-1:24 + >---< +1| private int value = 123; + +[Domain] = 1:4-1:28 + >------------------------< +1| private int value = 123; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.return.lambda.scope b/data/fixtures/scopes/java/value.return.lambda.scope new file mode 100644 index 0000000000..92aec8abee --- /dev/null +++ b/data/fixtures/scopes/java/value.return.lambda.scope @@ -0,0 +1,20 @@ +() -> 123 +--- + +[Content] = 0:6-0:9 + >---< +0| () -> 123 + +[Removal] = 0:5-0:9 + >----< +0| () -> 123 + +[Leading delimiter] = 0:5-0:6 + >-< +0| () -> 123 + +[Domain] = 0:0-0:9 + >---------< +0| () -> 123 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.return.scope b/data/fixtures/scopes/java/value.return.scope new file mode 100644 index 0000000000..e30150b26d --- /dev/null +++ b/data/fixtures/scopes/java/value.return.scope @@ -0,0 +1,24 @@ +public class MyClass { + public int foo() { + return 123; + } +} +--- + +[Content] = 2:15-2:18 + >---< +2| return 123; + +[Removal] = 2:14-2:18 + >----< +2| return 123; + +[Leading delimiter] = 2:14-2:15 + >-< +2| return 123; + +[Domain] = 2:8-2:19 + >-----------< +2| return 123; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.variable.scope b/data/fixtures/scopes/java/value.variable.scope new file mode 100644 index 0000000000..98eac669f7 --- /dev/null +++ b/data/fixtures/scopes/java/value.variable.scope @@ -0,0 +1,20 @@ +value = 123; +--- + +[Content] = 0:8-0:11 + >---< +0| value = 123; + +[Removal] = 0:5-0:11 + >------< +0| value = 123; + +[Leading delimiter] = 0:5-0:8 + >---< +0| value = 123; + +[Domain] = 0:0-0:12 + >------------< +0| value = 123; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 303250e659..65c4b69764 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -65,7 +65,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.constructor": supported, "name.field": supported, "name.foreach": supported, - "name.iteration.block": supported, "name.method": supported, "name.variable": supported, "namedFunction.constructor": supported, @@ -85,9 +84,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.typeArgument": supported, "type.typeArgument.iteration": supported, - "type.alias": supported, "type.argument.formal.constructor": supported, - "type.argument.formal.iteration": supported, "type.argument.formal.method": supported, "type.foreach": supported, "type.field": supported, @@ -100,7 +97,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.field": supported, "value.return": supported, "value.return.lambda": supported, - "value.typeAlias": supported, "value.variable": supported, "value.yield": supported, @@ -112,6 +108,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "className.iteration.document": unsupported, "name.iteration.document": unsupported, + "name.iteration.block": unsupported, "name.resource": unsupported, "name.resource.iteration": unsupported, @@ -168,15 +165,18 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.argument.actual.iteration": notApplicable, "value.argument.formal": notApplicable, "value.argument.formal.iteration": notApplicable, - "value.argument.formal.constructor": supported, - "value.argument.formal.constructor.iteration": supported, - "value.argument.formal.method": supported, - "value.argument.formal.method.iteration": supported, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, "value.mapPair": notApplicable, "value.mapPair.iteration": notApplicable, "value.variable.pattern": notApplicable, + "value.typeAlias": notApplicable, "type.argument.formal": notApplicable, + "type.argument.formal.iteration": notApplicable, + "type.alias": notApplicable, section: notApplicable, "section.iteration.document": notApplicable, From 143a5c5c6d868b88a82a8cd9afe4e158c880cd32 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 12 Feb 2025 09:39:14 +0100 Subject: [PATCH 5/6] Clean up --- packages/common/src/scopeSupportFacets/java.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 65c4b69764..67a8604bd1 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -68,7 +68,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.method": supported, "name.variable": supported, "namedFunction.constructor": supported, - "namedFunction.iteration.document": supported, "namedFunction.method": supported, ifStatement: supported, @@ -98,7 +97,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.return": supported, "value.return.lambda": supported, "value.variable": supported, - "value.yield": supported, // Unsupported @@ -122,6 +120,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.resource": unsupported, "value.resource.iteration": unsupported, + "namedFunction.iteration.document": unsupported, "namedFunction.method.iteration.class": unsupported, "functionName.iteration.block": unsupported, @@ -173,6 +172,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.mapPair.iteration": notApplicable, "value.variable.pattern": notApplicable, "value.typeAlias": notApplicable, + "value.yield": notApplicable, "type.argument.formal": notApplicable, "type.argument.formal.iteration": notApplicable, From 017018fdf457da599630c92f5bb307b4ef21b6a5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 12 Feb 2025 12:06:16 +0100 Subject: [PATCH 6/6] Remove empty line --- queries/java.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/queries/java.scm b/queries/java.scm index 0cb9558c0a..3f22a3c6c7 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -242,7 +242,6 @@ (formal_parameters . "(" @name.iteration.start.endOf - ")" @name.iteration.end.startOf . ) @name.iteration.domain