diff --git a/data/fixtures/scopes/java/interior.class.scope b/data/fixtures/scopes/java/interior.class.scope new file mode 100644 index 0000000000..5390112f29 --- /dev/null +++ b/data/fixtures/scopes/java/interior.class.scope @@ -0,0 +1,25 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:11-0:12 + >-< +0| class Foo { } + +[#2 Domain] = 0:10-0:13 + >---< +0| class Foo { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.class2.scope b/data/fixtures/scopes/java/interior.class2.scope new file mode 100644 index 0000000000..48ed5df4de --- /dev/null +++ b/data/fixtures/scopes/java/interior.class2.scope @@ -0,0 +1,25 @@ +public class Foo { } +--- + +[#1 Content] = +[#1 Removal] = 0:18-0:19 + >-< +0| public class Foo { } + +[#1 Domain] = 0:0-0:20 + >--------------------< +0| public class Foo { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:18-0:19 + >-< +0| public class Foo { } + +[#2 Domain] = 0:17-0:20 + >---< +0| public class Foo { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.function.scope b/data/fixtures/scopes/java/interior.function.scope new file mode 100644 index 0000000000..f6ec2af746 --- /dev/null +++ b/data/fixtures/scopes/java/interior.function.scope @@ -0,0 +1,81 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = 1:4-1:18 + >--------------< +1| void bar() { } + +[#1 Removal] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:18 + >--------------< +1| void bar() { } + +[#2 Removal] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + +[#2 Domain] = 0:10-2:1 + >- +0| class Foo { +1| void bar() { } +2| } + -< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:16-1:17 + >-< +1| void bar() { } + +[#3 Domain] = 1:4-1:18 + >--------------< +1| void bar() { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:13-1:13 + >< +1| void bar() { } + +[#4 Domain] = 1:12-1:14 + >--< +1| void bar() { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:16-1:17 + >-< +1| void bar() { } + +[#5 Domain] = 1:15-1:18 + >---< +1| void bar() { } + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.function2.scope b/data/fixtures/scopes/java/interior.function2.scope new file mode 100644 index 0000000000..4e6bb1ebee --- /dev/null +++ b/data/fixtures/scopes/java/interior.function2.scope @@ -0,0 +1,81 @@ +class Foo { + public void bar() { } +} +--- + +[#1 Content] = 1:4-1:25 + >---------------------< +1| public void bar() { } + +[#1 Removal] = 0:11-2:0 + > +0| class Foo { +1| public void bar() { } +2| } + < + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| public void bar() { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:25 + >---------------------< +1| public void bar() { } + +[#2 Removal] = 0:11-2:0 + > +0| class Foo { +1| public void bar() { } +2| } + < + +[#2 Domain] = 0:10-2:1 + >- +0| class Foo { +1| public void bar() { } +2| } + -< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:23-1:24 + >-< +1| public void bar() { } + +[#3 Domain] = 1:4-1:25 + >---------------------< +1| public void bar() { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:20-1:20 + >< +1| public void bar() { } + +[#4 Domain] = 1:19-1:21 + >--< +1| public void bar() { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:23-1:24 + >-< +1| public void bar() { } + +[#5 Domain] = 1:22-1:25 + >---< +1| public void bar() { } + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.if.scope b/data/fixtures/scopes/java/interior.if.scope new file mode 100644 index 0000000000..52ac91931a --- /dev/null +++ b/data/fixtures/scopes/java/interior.if.scope @@ -0,0 +1,99 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Domain] = 0:0-0:13 + >-------------< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:8 + >----< +0| if (true) { } + +[#2 Domain] = 0:3-0:9 + >------< +0| if (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:11-0:12 + >-< +0| if (true) { } + +[#3 Domain] = 0:10-0:13 + >---< +0| if (true) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#4 Domain] = 1:0-1:19 + >-------------------< +1| else if (false) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:9-1:14 + >-----< +1| else if (false) { } + +[#5 Domain] = 1:8-1:15 + >-------< +1| else if (false) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 1:17-1:18 + >-< +1| else if (false) { } + +[#6 Domain] = 1:16-1:19 + >---< +1| else if (false) { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:6-2:7 + >-< +2| else { } + +[#7 Domain] = 2:0-2:8 + >--------< +2| else { } + +[#7 Insertion delimiter] = " " + + +[#8 Content] = +[#8 Removal] = 2:6-2:7 + >-< +2| else { } + +[#8 Domain] = 2:5-2:8 + >---< +2| else { } + +[#8 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.lambda.scope b/data/fixtures/scopes/java/interior.lambda.scope new file mode 100644 index 0000000000..3066da5e6b --- /dev/null +++ b/data/fixtures/scopes/java/interior.lambda.scope @@ -0,0 +1,37 @@ +() -> { } +--- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () -> { } + +[#1 Domain] = 0:0-0:2 + >--< +0| () -> { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:7-0:8 + >-< +0| () -> { } + +[#2 Domain] = 0:0-0:9 + >---------< +0| () -> { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:7-0:8 + >-< +0| () -> { } + +[#3 Domain] = 0:6-0:9 + >---< +0| () -> { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.lambda2.scope b/data/fixtures/scopes/java/interior.lambda2.scope new file mode 100644 index 0000000000..3a555ea9b5 --- /dev/null +++ b/data/fixtures/scopes/java/interior.lambda2.scope @@ -0,0 +1,25 @@ +() -> 0; +--- + +[#1 Content] = +[#1 Removal] = 0:1-0:1 + >< +0| () -> 0; + +[#1 Domain] = 0:0-0:2 + >--< +0| () -> 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:6-0:7 + >-< +0| () -> 0; + +[#2 Domain] = 0:0-0:7 + >-------< +0| () -> 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.loop.scope b/data/fixtures/scopes/java/interior.loop.scope new file mode 100644 index 0000000000..e1cf88df36 --- /dev/null +++ b/data/fixtures/scopes/java/interior.loop.scope @@ -0,0 +1,37 @@ +for (int i = 0; i < size; ++i) { } +--- + +[#1 Content] = +[#1 Removal] = 0:32-0:33 + >-< +0| for (int i = 0; i < size; ++i) { } + +[#1 Domain] = 0:0-0:34 + >----------------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:29 + >------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#2 Domain] = 0:4-0:30 + >--------------------------< +0| for (int i = 0; i < size; ++i) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:32-0:33 + >-< +0| for (int i = 0; i < size; ++i) { } + +[#3 Domain] = 0:31-0:34 + >---< +0| for (int i = 0; i < size; ++i) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.loop2.scope b/data/fixtures/scopes/java/interior.loop2.scope new file mode 100644 index 0000000000..3e16181107 --- /dev/null +++ b/data/fixtures/scopes/java/interior.loop2.scope @@ -0,0 +1,37 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Removal] = 0:14-0:15 + >-< +0| while (true) { } + +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:7-0:11 + >----< +0| while (true) { } + +[#2 Domain] = 0:6-0:12 + >------< +0| while (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:14-0:15 + >-< +0| while (true) { } + +[#3 Domain] = 0:13-0:16 + >---< +0| while (true) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.loop3.scope b/data/fixtures/scopes/java/interior.loop3.scope new file mode 100644 index 0000000000..d1833e59d1 --- /dev/null +++ b/data/fixtures/scopes/java/interior.loop3.scope @@ -0,0 +1,37 @@ +do { } while (true); +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#1 Domain] = 0:0-0:20 + >--------------------< +0| do { } while (true); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:4-0:5 + >-< +0| do { } while (true); + +[#2 Domain] = 0:3-0:6 + >---< +0| do { } while (true); + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:14-0:18 + >----< +0| do { } while (true); + +[#3 Domain] = 0:13-0:19 + >------< +0| do { } while (true); + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.loop4.scope b/data/fixtures/scopes/java/interior.loop4.scope new file mode 100644 index 0000000000..634c2411cf --- /dev/null +++ b/data/fixtures/scopes/java/interior.loop4.scope @@ -0,0 +1,37 @@ +for (final int v : values) { } +--- + +[#1 Content] = +[#1 Removal] = 0:28-0:29 + >-< +0| for (final int v : values) { } + +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| for (final int v : values) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:25 + >--------------------< +0| for (final int v : values) { } + +[#2 Domain] = 0:4-0:26 + >----------------------< +0| for (final int v : values) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:28-0:29 + >-< +0| for (final int v : values) { } + +[#3 Domain] = 0:27-0:30 + >---< +0| for (final int v : values) { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.resource.scope b/data/fixtures/scopes/java/interior.resource.scope new file mode 100644 index 0000000000..1fdf6390af --- /dev/null +++ b/data/fixtures/scopes/java/interior.resource.scope @@ -0,0 +1,49 @@ +try (PrintWriter writer = create()) { } +--- + +[#1 Content] = +[#1 Removal] = 0:37-0:38 + >-< +0| try (PrintWriter writer = create()) { } + +[#1 Domain] = 0:0-0:39 + >---------------------------------------< +0| try (PrintWriter writer = create()) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:34 + >-----------------------------< +0| try (PrintWriter writer = create()) { } + +[#2 Domain] = 0:4-0:35 + >-------------------------------< +0| try (PrintWriter writer = create()) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 0:33-0:33 + >< +0| try (PrintWriter writer = create()) { } + +[#3 Domain] = 0:32-0:34 + >--< +0| try (PrintWriter writer = create()) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 0:37-0:38 + >-< +0| try (PrintWriter writer = create()) { } + +[#4 Domain] = 0:36-0:39 + >---< +0| try (PrintWriter writer = create()) { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.switchCase.scope b/data/fixtures/scopes/java/interior.switchCase.scope new file mode 100644 index 0000000000..58797959fa --- /dev/null +++ b/data/fixtures/scopes/java/interior.switchCase.scope @@ -0,0 +1,181 @@ +switch (value) { + case 0: + foo; + break; + case 1: { + break; + } + default: + break; +} +--- + +[#1 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#1 Removal] = 0:16-9:0 + > +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#1 Domain] = 0:0-9:1 + >---------------- +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:8-0:13 + >-----< +0| switch (value) { + +[#2 Domain] = 0:7-0:14 + >-------< +0| switch (value) { + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:4-8:14 + >------- +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; + --------------< + +[#3 Removal] = 0:16-9:0 + > +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + < + +[#3 Domain] = 0:15-9:1 + >- +0| switch (value) { +1| case 0: +2| foo; +3| break; +4| case 1: { +5| break; +6| } +7| default: +8| break; +9| } + -< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 2:8-3:14 + >---- +2| foo; +3| break; + --------------< + +[#4 Domain] = 1:4-3:14 + >------- +1| case 0: +2| foo; +3| break; + --------------< + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 5:8-5:14 + >------< +5| break; + +[#5 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#5 Domain] = 4:4-6:5 + >--------- +4| case 1: { +5| break; +6| } + -----< + +[#5 Insertion delimiter] = " " + + +[#6 Content] = 5:8-5:14 + >------< +5| break; + +[#6 Removal] = 4:13-6:4 + > +4| case 1: { +5| break; +6| } + ----< + +[#6 Domain] = 4:12-6:5 + >- +4| case 1: { +5| break; +6| } + -----< + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 8:8-8:14 + >------< +8| break; + +[#7 Domain] = 7:4-8:14 + >-------- +7| default: +8| break; + --------------< + +[#7 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.ternary.scope b/data/fixtures/scopes/java/interior.ternary.scope new file mode 100644 index 0000000000..79ef01735b --- /dev/null +++ b/data/fixtures/scopes/java/interior.ternary.scope @@ -0,0 +1,28 @@ +true ? 1 : 0; +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:4 + >----< +0| true ? 1 : 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:7-0:8 + >-< +0| true ? 1 : 0; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 0:11-0:12 + >-< +0| true ? 1 : 0; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/interior.try.scope b/data/fixtures/scopes/java/interior.try.scope new file mode 100644 index 0000000000..87dc4ae08a --- /dev/null +++ b/data/fixtures/scopes/java/interior.try.scope @@ -0,0 +1,87 @@ +try { } +catch(Exception ex) { } +finally { } +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:6 + >-< +0| try { } + +[#1 Domain] = 0:0-0:7 + >-------< +0| try { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:5-0:6 + >-< +0| try { } + +[#2 Domain] = 0:4-0:7 + >---< +0| try { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:21-1:22 + >-< +1| catch(Exception ex) { } + +[#3 Domain] = 1:0-1:23 + >-----------------------< +1| catch(Exception ex) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 1:6-1:18 + >------------< +1| catch(Exception ex) { } + +[#4 Domain] = 1:5-1:19 + >--------------< +1| catch(Exception ex) { } + +[#4 Insertion delimiter] = " " + + +[#5 Content] = +[#5 Removal] = 1:21-1:22 + >-< +1| catch(Exception ex) { } + +[#5 Domain] = 1:20-1:23 + >---< +1| catch(Exception ex) { } + +[#5 Insertion delimiter] = " " + + +[#6 Content] = +[#6 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#6 Domain] = 2:0-2:11 + >-----------< +2| finally { } + +[#6 Insertion delimiter] = " " + + +[#7 Content] = +[#7 Removal] = 2:9-2:10 + >-< +2| finally { } + +[#7 Domain] = 2:8-2:11 + >---< +2| finally { } + +[#7 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 6f22ce47b1..34c9132393 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -140,89 +140,102 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": supported, "value.resource": supported, - // 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, + "interior.class": supported, + "interior.function": supported, + "interior.if": supported, + "interior.lambda": supported, + "interior.loop": supported, + "interior.switchCase": supported, + "interior.ternary": supported, + "interior.try": supported, + "interior.resource": supported, + + /* UNSUPPORTED */ fieldAccess: unsupported, - // Not Applicable + /* NOT APPLICABLE */ + // Functions (not methods) + namedFunction: notApplicable, + "namedFunction.iteration.document": notApplicable, + "namedFunction.iteration.block": notApplicable, + functionName: notApplicable, + "functionName.iteration.document": notApplicable, + "functionName.iteration.block": notApplicable, "argument.formal": notApplicable, "argument.formal.iteration": notApplicable, - "argumentList.formal.empty": notApplicable, "argumentList.formal.singleLine": notApplicable, "argumentList.formal.multiLine": notApplicable, - - "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, + "type.argument.formal": notApplicable, + "type.argument.formal.iteration": notApplicable, + + // Element and tags + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Keyword argument + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + + // Pattern destructing + "name.assignment.pattern": notApplicable, "name.variable.pattern": notApplicable, - "name.resource.iteration": notApplicable, + "value.variable.pattern": notApplicable, + // Map literal + map: notApplicable, "key.mapPair": notApplicable, "key.mapPair.iteration": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, - "value.attribute": notApplicable, - "value.argument.actual": notApplicable, - "value.argument.actual.iteration": notApplicable, + // Default argument value "value.argument.formal": notApplicable, "value.argument.formal.iteration": notApplicable, "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, - "value.yield": notApplicable, - "value.resource.iteration": notApplicable, - "type.argument.formal": notApplicable, - "type.argument.formal.iteration": notApplicable, + // Type alias "type.alias": notApplicable, - "type.resource.iteration": notApplicable, + "value.typeAlias": notApplicable, + // Section section: notApplicable, "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, - element: notApplicable, - tags: notApplicable, - startTag: notApplicable, - endTag: notApplicable, - "textFragment.element": notApplicable, + // Command + command: notApplicable, + "interior.command": notApplicable, - namedFunction: notApplicable, - "namedFunction.iteration.document": notApplicable, - "namedFunction.iteration.block": notApplicable, + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, - "functionName.iteration.document": notApplicable, - "functionName.iteration.block": notApplicable, + // Multiple resources + "value.resource.iteration": notApplicable, + "type.resource.iteration": notApplicable, + "name.resource.iteration": notApplicable, + // Miscellaneous + "value.yield": notApplicable, pairDelimiter: notApplicable, - functionName: notApplicable, - map: notApplicable, regularExpression: notApplicable, environment: notApplicable, - "interior.cell": notApplicable, - "interior.command": notApplicable, - "key.attribute": notApplicable, - notebookCell: notApplicable, - attribute: notApplicable, - command: notApplicable, }; diff --git a/queries/java.scm b/queries/java.scm index 6205417f94..e98080cf48 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -69,22 +69,34 @@ "}" @type.iteration.end.startOf @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf ) -;;!! for (...) { } -;;! ^ +;;!! xxx { } +;;! ^ +( + (_ + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) + ) @_.domain + (#not-type? @_.domain try_statement) +) + +;;!! { } +;;! ^ (_ - body: (_ - "{" @name.iteration.start.endOf @statement.iteration.start.endOf - "}" @name.iteration.end.startOf @statement.iteration.end.startOf - ) + "{" @name.iteration.start.endOf @statement.iteration.start.endOf + "}" @name.iteration.end.startOf @statement.iteration.end.startOf ) -;;!! if (true) { } -;;! ^ -(if_statement - (block - "{" @name.iteration.start.endOf @statement.iteration.start.endOf - "}" @name.iteration.end.startOf @statement.iteration.end.startOf - ) +( + (_ + !body + (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) + ) @_.domain + (#not-type? @_.domain try_statement if_statement) ) ;;!! void myFunk() {} @@ -100,13 +112,6 @@ ;;! ^^^^^^^^^^^^^^^ (lambda_expression) @anonymousFunction -;;!! if (value) {} -;;! ^^^^^^^^^^^^^ -( - (if_statement) @ifStatement - (#not-parent-type? @ifStatement "if_statement") -) - ;;!! "string" ;;! ^^^^^^^^ ( @@ -179,6 +184,17 @@ ) ) @condition.domain +;;!! case 0: break; +;;! ^^^^^^ +(_ + (switch_label) + . + (_) @interior.start + (_)? @interior.end + . + (#not-type? @interior.start "block") +) @_.domain + (switch_expression body: (_ "{" @branch.iteration.start.endOf @condition.iteration.start.endOf @@ -186,13 +202,23 @@ ) ) @condition.iteration.domain @branch.iteration.domain +;;!! if (value) {} +;;! ^^^^^^^^^^^^^ +( + (if_statement) @ifStatement + (#not-parent-type? @ifStatement "if_statement") +) + ;;!! if () {} ;;! ^^^^^^^^ ( (if_statement - "if" @branch.start @branch.removal.start + "if" @branch.start @branch.removal.start @interior.domain.start.startOf condition: (_) @condition - consequence: (block) @branch.end @branch.removal.end + consequence: (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @branch.removal.end @interior.domain.end.endOf alternative: (if_statement)? @branch.removal.end.startOf ) @condition.domain (#not-parent-type? @condition.domain "if_statement") @@ -202,10 +228,13 @@ ;;!! else if () {} ;;! ^^^^^^^^^^^^^ (if_statement - "else" @branch.start @condition.domain.start + "else" @branch.start @condition.domain.start @interior.domain.start.startOf alternative: (if_statement condition: (_) @condition - consequence: (block) @branch.end @condition.domain.end + consequence: (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @condition.domain.end @interior.domain.end.endOf (#child-range! @condition 0 -1 true true) ) ) @@ -213,8 +242,11 @@ ;;!! else {} ;;! ^^^^^^^ (if_statement - "else" @branch.start - alternative: (block) @branch.end + "else" @branch.start @interior.domain.start.startOf + alternative: (block + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @interior.domain.end.endOf ) ( @@ -225,8 +257,11 @@ ;;!! try {} ;;! ^^^^^^ (try_statement - "try" @branch.start - body: (_) @branch.end + "try" @branch.start @interior.domain.start.startOf + body: (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @branch.end @interior.domain.end.endOf ) ;;!! catch (Exception e) {} @@ -269,11 +304,13 @@ ;;!! true ? 1 : 2 (ternary_expression - condition: (_) @condition - consequence: (_) @branch + condition: (_) @condition @interior ) @condition.domain (ternary_expression - alternative: (_) @branch + consequence: (_) @branch @interior +) +(ternary_expression + alternative: (_) @branch @interior ) ;;!! true ? 1 : 2 @@ -458,7 +495,7 @@ ;;! ^^^^^^^^^^^^^^ ;;! --------------------- (lambda_expression - body: (_) @value + body: (_) @value @interior (#not-type? @value block) ) @_.domain