diff --git a/data/fixtures/scopes/java/collectionItem.unenclosed.iteration.scope b/data/fixtures/scopes/java/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..323bff9b47 --- /dev/null +++ b/data/fixtures/scopes/java/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,33 @@ +public class MyClass { + String foo, bar; +} +--- + +[#1 Range] = 1:4-1:20 + >----------------< +1| String foo, bar; + +[#1 Domain] = 0:22-2:0 + > +0| public class MyClass { +1| String foo, bar; +2| } + < + + +[#2 Range] = 1:4-1:20 + >----------------< +1| String foo, bar; + +[#2 Domain] = 1:0-1:20 + >--------------------< +1| String foo, bar; + + +[#3 Range] = 1:11-1:19 + >--------< +1| String foo, bar; + +[#3 Domain] = 1:4-1:20 + >----------------< +1| String foo, bar; diff --git a/data/fixtures/scopes/java/collectionItem.unenclosed.iteration2.scope b/data/fixtures/scopes/java/collectionItem.unenclosed.iteration2.scope new file mode 100644 index 0000000000..2920e986f2 --- /dev/null +++ b/data/fixtures/scopes/java/collectionItem.unenclosed.iteration2.scope @@ -0,0 +1,58 @@ +public class MyClass { + public void myFunk() { + String foo, bar; + } +} +--- + +[#1 Range] = 1:4-3:5 + >---------------------- +1| public void myFunk() { +2| String foo, bar; +3| } + -----< + +[#1 Domain] = 0:22-4:0 + > +0| public class MyClass { +1| public void myFunk() { +2| String foo, bar; +3| } +4| } + < + + +[#2 Range] = +[#2 Domain] = 1:23-1:23 + >< +1| public void myFunk() { + + +[#3 Range] = 2:8-2:24 + >----------------< +2| String foo, bar; + +[#3 Domain] = 1:26-3:4 + > +1| public void myFunk() { +2| String foo, bar; +3| } + ----< + + +[#4 Range] = 2:8-2:24 + >----------------< +2| String foo, bar; + +[#4 Domain] = 2:0-2:24 + >------------------------< +2| String foo, bar; + + +[#5 Range] = 2:15-2:23 + >--------< +2| String foo, bar; + +[#5 Domain] = 2:8-2:24 + >----------------< +2| String foo, bar; diff --git a/data/fixtures/scopes/java/collectionItem.unenclosed.scope b/data/fixtures/scopes/java/collectionItem.unenclosed.scope new file mode 100644 index 0000000000..999c5c0da9 --- /dev/null +++ b/data/fixtures/scopes/java/collectionItem.unenclosed.scope @@ -0,0 +1,67 @@ +public class MyClass { + String foo, bar; +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:14 + >----------< +1| String foo, bar; + +[#1 Removal] = 1:4-1:16 + >------------< +1| String foo, bar; + +[#1 Trailing delimiter] = 1:14-1:16 + >--< +1| String foo, bar; + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 1:11-1:14 + >---< +1| String foo, bar; + +[#2 Removal] = 1:11-1:16 + >-----< +1| String foo, bar; + +[#2 Trailing delimiter] = 1:14-1:16 + >--< +1| String foo, bar; + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 1:16-1:19 + >---< +1| String foo, bar; + +[#3 Removal] = 1:14-1:19 + >-----< +1| String foo, bar; + +[#3 Leading delimiter] = 1:14-1:16 + >--< +1| String foo, bar; + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 1:16-1:20 + >----< +1| String foo, bar; + +[#4 Removal] = 1:14-1:20 + >------< +1| String foo, bar; + +[#4 Leading delimiter] = 1:14-1:16 + >--< +1| String foo, bar; + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/java/collectionItem.unenclosed2.scope b/data/fixtures/scopes/java/collectionItem.unenclosed2.scope new file mode 100644 index 0000000000..ccc7682a58 --- /dev/null +++ b/data/fixtures/scopes/java/collectionItem.unenclosed2.scope @@ -0,0 +1,91 @@ +public class MyClass { + public void myFunk() { + String foo, bar; + } +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-3:5 + >---------------------- +1| public void myFunk() { +2| String foo, bar; +3| } + -----< + +[#1 Removal] = 1:0-3:5 + >-------------------------- +1| public void myFunk() { +2| String foo, bar; +3| } + -----< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| public void myFunk() { + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:8-2:18 + >----------< +2| String foo, bar; + +[#2 Removal] = 2:8-2:20 + >------------< +2| String foo, bar; + +[#2 Trailing delimiter] = 2:18-2:20 + >--< +2| String foo, bar; + +[#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 2:15-2:18 + >---< +2| String foo, bar; + +[#3 Removal] = 2:15-2:20 + >-----< +2| String foo, bar; + +[#3 Trailing delimiter] = 2:18-2:20 + >--< +2| String foo, bar; + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 2:20-2:23 + >---< +2| String foo, bar; + +[#4 Removal] = 2:18-2:23 + >-----< +2| String foo, bar; + +[#4 Leading delimiter] = 2:18-2:20 + >--< +2| String foo, bar; + +[#4 Insertion delimiter] = ", " + + +[#5 Content] = +[#5 Domain] = 2:20-2:24 + >----< +2| String foo, bar; + +[#5 Removal] = 2:18-2:24 + >------< +2| String foo, bar; + +[#5 Leading delimiter] = 2:18-2:20 + >--< +2| String foo, bar; + +[#5 Insertion delimiter] = ",\n" diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index f6b27eeb72..6f9bda944a 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -21,14 +21,17 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "argument.actual": supported, "argument.actual.iteration": supported, - element: notApplicable, - tags: notApplicable, - attribute: notApplicable, - "key.attribute": notApplicable, - "value.attribute": notApplicable, + "collectionItem.unenclosed": supported, + "collectionItem.unenclosed.iteration": supported, "branch.if": supported, "branch.if.iteration": supported, "branch.try": supported, "branch.try.iteration": supported, + + element: notApplicable, + tags: notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, }; diff --git a/queries/java.scm b/queries/java.scm index c438a00f71..10e1e28f50 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -316,6 +316,7 @@ value: (_)? @value @name.trailing.startOf ) ) @_.domain + (field_declaration (variable_declarator name: (_) @name @value.leading.endOf @@ -323,6 +324,49 @@ ) ) @_.domain +;;!! int foo, bar; +;;! ^^^ ^^^ +( + (local_variable_declaration + type: (_) + (variable_declarator)? @_.leading.endOf + . + (variable_declarator) @collectionItem + . + (variable_declarator)? @_.trailing.startOf + ) + (#insertion-delimiter! @collectionItem ", ") +) + +( + (field_declaration + type: (_) + (variable_declarator)? @_.leading.endOf + . + (variable_declarator) @collectionItem + . + (variable_declarator)? @_.trailing.startOf + ) + (#insertion-delimiter! @collectionItem ", ") +) + +;;!! int foo, bar; +;;! ^^^^^^^^ +;;! ------------- +(local_variable_declaration + type: (_) + . + (_) @collectionItem.iteration.start.startOf + ";"? @collectionItem.iteration.end.startOf +) @collectionItem.iteration.domain + +(field_declaration + type: (_) + . + (_) @collectionItem.iteration.start.startOf + ";"? @collectionItem.iteration.end.startOf +) @collectionItem.iteration.domain + ;;!! value = 1; ;;! ^ ;;! xxxx