diff --git a/data/fixtures/scopes/java/branch.loop.scope b/data/fixtures/scopes/java/branch.loop.scope new file mode 100644 index 0000000000..2d18232ba5 --- /dev/null +++ b/data/fixtures/scopes/java/branch.loop.scope @@ -0,0 +1,10 @@ +for (int i = 0; i < size; ++i) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:34 + >----------------------------------< +0| for (int i = 0; i < size; ++i) { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/branch.loop2.scope b/data/fixtures/scopes/java/branch.loop2.scope new file mode 100644 index 0000000000..a7e3be936d --- /dev/null +++ b/data/fixtures/scopes/java/branch.loop2.scope @@ -0,0 +1,10 @@ +for (final int v : values) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:30 + >------------------------------< +0| for (final int v : values) { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/branch.loop3.scope b/data/fixtures/scopes/java/branch.loop3.scope new file mode 100644 index 0000000000..5beb4d4731 --- /dev/null +++ b/data/fixtures/scopes/java/branch.loop3.scope @@ -0,0 +1,10 @@ +while(true) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| while(true) { } + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/branch.loop4.scope b/data/fixtures/scopes/java/branch.loop4.scope new file mode 100644 index 0000000000..25f6d347bf --- /dev/null +++ b/data/fixtures/scopes/java/branch.loop4.scope @@ -0,0 +1,10 @@ +do { } while(true); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| do { } while(true); + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/java/class.iteration.block.scope b/data/fixtures/scopes/java/class.iteration.block.scope new file mode 100644 index 0000000000..f3ca810401 --- /dev/null +++ b/data/fixtures/scopes/java/class.iteration.block.scope @@ -0,0 +1,13 @@ +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:22-0:23 + >-< +0| public class MyClass { } diff --git a/data/fixtures/scopes/java/class.iteration.document.scope b/data/fixtures/scopes/java/class.iteration.document.scope new file mode 100644 index 0000000000..51de20803a --- /dev/null +++ b/data/fixtures/scopes/java/class.iteration.document.scope @@ -0,0 +1,14 @@ + +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 1:0-1:24 + >------------------------< +1| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 1:22-1:23 + >-< +1| public class MyClass { } diff --git a/data/fixtures/scopes/java/className.iteration.block.scope b/data/fixtures/scopes/java/className.iteration.block.scope new file mode 100644 index 0000000000..f3ca810401 --- /dev/null +++ b/data/fixtures/scopes/java/className.iteration.block.scope @@ -0,0 +1,13 @@ +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:22-0:23 + >-< +0| public class MyClass { } diff --git a/data/fixtures/scopes/java/className.iteration.document.scope b/data/fixtures/scopes/java/className.iteration.document.scope new file mode 100644 index 0000000000..51de20803a --- /dev/null +++ b/data/fixtures/scopes/java/className.iteration.document.scope @@ -0,0 +1,14 @@ + +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 1:0-1:24 + >------------------------< +1| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 1:22-1:23 + >-< +1| public class MyClass { } diff --git a/data/fixtures/scopes/java/functionName.method.iteration.class.scope b/data/fixtures/scopes/java/functionName.method.iteration.class.scope new file mode 100644 index 0000000000..4eaba49f3c --- /dev/null +++ b/data/fixtures/scopes/java/functionName.method.iteration.class.scope @@ -0,0 +1,7 @@ +class MyClass { } +--- + +[Range] = +[Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope index 15f2dc4312..50d913086a 100644 --- a/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/java/name.argument.formal.constructor.iteration.scope @@ -3,10 +3,34 @@ public class MyClass { } --- -[Range] = 1:19-1:41 +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public MyClass(String name, int value) { } +2| } + -< + + +[#2 Range] = +[#2 Domain] = 0:22-2:0 + > +0| public class MyClass { +1| public MyClass(String name, int value) { } +2| } + < + + +[#3 Range] = 1:19-1:41 >----------------------< 1| public MyClass(String name, int value) { } -[Domain] = 1:18-1:42 +[#3 Domain] = 1:18-1:42 >------------------------< 1| public MyClass(String name, int value) { } + + +[#4 Range] = +[#4 Domain] = 1:44-1:45 + >-< +1| public MyClass(String name, int value) { } diff --git a/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope index 073b8b3ae0..16fe113757 100644 --- a/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/java/name.argument.formal.method.iteration.scope @@ -3,10 +3,34 @@ public class MyClass { } --- -[Range] = 1:20-1:42 +[#1 Range] = +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public void foo(String name, int value) { } +2| } + -< + + +[#2 Range] = +[#2 Domain] = 0:22-2:0 + > +0| public class MyClass { +1| public void foo(String name, int value) { } +2| } + < + + +[#3 Range] = 1:20-1:42 >----------------------< 1| public void foo(String name, int value) { } -[Domain] = 1:19-1:43 +[#3 Domain] = 1:19-1:43 >------------------------< 1| public void foo(String name, int value) { } + + +[#4 Range] = +[#4 Domain] = 1:45-1:46 + >-< +1| public void foo(String name, int value) { } diff --git a/data/fixtures/scopes/java/name.iteration.block.scope b/data/fixtures/scopes/java/name.iteration.block.scope new file mode 100644 index 0000000000..a6a24213a1 --- /dev/null +++ b/data/fixtures/scopes/java/name.iteration.block.scope @@ -0,0 +1,51 @@ +public class MyClass { + public void myFunk() { + if (true) { } + } +} +--- + +[#1 Range] = +[#1 Domain] = 0:0-4:1 + >---------------------- +0| public class MyClass { +1| public void myFunk() { +2| if (true) { } +3| } +4| } + -< + + +[#2 Range] = +[#2 Domain] = 0:22-4:0 + > +0| public class MyClass { +1| public void myFunk() { +2| if (true) { } +3| } +4| } + < + + +[#3 Range] = 1:22-1:22 + >< +1| public void myFunk() { + +[#3 Domain] = 1:21-1:23 + >--< +1| public void myFunk() { + + +[#4 Range] = +[#4 Domain] = 1:25-3:3 + > +1| public void myFunk() { +2| if (true) { } +3| } + ---< + + +[#5 Range] = +[#5 Domain] = 2:15-2:16 + >-< +2| if (true) { } diff --git a/data/fixtures/scopes/java/name.iteration.document.scope b/data/fixtures/scopes/java/name.iteration.document.scope new file mode 100644 index 0000000000..51de20803a --- /dev/null +++ b/data/fixtures/scopes/java/name.iteration.document.scope @@ -0,0 +1,14 @@ + +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 1:0-1:24 + >------------------------< +1| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 1:22-1:23 + >-< +1| public class MyClass { } diff --git a/data/fixtures/scopes/java/name.resource.scope b/data/fixtures/scopes/java/name.resource.scope new file mode 100644 index 0000000000..ad10cad11b --- /dev/null +++ b/data/fixtures/scopes/java/name.resource.scope @@ -0,0 +1,24 @@ +try (PrintWriter writer = create()) { } +--- + +[Content] = 0:17-0:23 + >------< +0| try (PrintWriter writer = create()) { } + +[Removal] = 0:17-0:24 + >-------< +0| try (PrintWriter writer = create()) { } + +[Leading delimiter] = 0:16-0:17 + >-< +0| try (PrintWriter writer = create()) { } + +[Trailing delimiter] = 0:23-0:24 + >-< +0| try (PrintWriter writer = create()) { } + +[Domain] = 0:0-0:39 + >---------------------------------------< +0| try (PrintWriter writer = create()) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/namedFunction.method.iteration.class.scope b/data/fixtures/scopes/java/namedFunction.method.iteration.class.scope new file mode 100644 index 0000000000..4eaba49f3c --- /dev/null +++ b/data/fixtures/scopes/java/namedFunction.method.iteration.class.scope @@ -0,0 +1,7 @@ +class MyClass { } +--- + +[Range] = +[Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/java/statement.iteration.block.scope b/data/fixtures/scopes/java/statement.iteration.block.scope new file mode 100644 index 0000000000..8c9fc9cd8f --- /dev/null +++ b/data/fixtures/scopes/java/statement.iteration.block.scope @@ -0,0 +1,52 @@ +public class MyClass { + public void myFunk() { + if (true) { } + while (true) { } + } +} +--- + +[#1 Range] = +[#1 Domain] = 0:0-5:1 + >---------------------- +0| public class MyClass { +1| public void myFunk() { +2| if (true) { } +3| while (true) { } +4| } +5| } + -< + + +[#2 Range] = +[#2 Domain] = 0:22-5:0 + > +0| public class MyClass { +1| public void myFunk() { +2| if (true) { } +3| while (true) { } +4| } +5| } + < + + +[#3 Range] = +[#3 Domain] = 1:25-4:3 + > +1| public void myFunk() { +2| if (true) { } +3| while (true) { } +4| } + ---< + + +[#4 Range] = +[#4 Domain] = 2:15-2:16 + >-< +2| if (true) { } + + +[#5 Range] = +[#5 Domain] = 3:18-3:19 + >-< +3| while (true) { } diff --git a/data/fixtures/scopes/java/statement.iteration.document.scope b/data/fixtures/scopes/java/statement.iteration.document.scope new file mode 100644 index 0000000000..51de20803a --- /dev/null +++ b/data/fixtures/scopes/java/statement.iteration.document.scope @@ -0,0 +1,14 @@ + +public class MyClass { } +--- + +[#1 Range] = +[#1 Domain] = 1:0-1:24 + >------------------------< +1| public class MyClass { } + + +[#2 Range] = +[#2 Domain] = 1:22-1:23 + >-< +1| public class MyClass { } diff --git a/data/fixtures/scopes/java/string.multiLine.scope b/data/fixtures/scopes/java/string.multiLine.scope new file mode 100644 index 0000000000..322d7a6860 --- /dev/null +++ b/data/fixtures/scopes/java/string.multiLine.scope @@ -0,0 +1,17 @@ +""" +Hello +world +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-3:3 + >--- +0| """ +1| Hello +2| world +3| """ + ---< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/textFragment.string.multiLine.scope b/data/fixtures/scopes/java/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..a5531210d9 --- /dev/null +++ b/data/fixtures/scopes/java/textFragment.string.multiLine.scope @@ -0,0 +1,17 @@ +""" +Hello +world +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:3-3:0 + > +0| """ +1| Hello +2| world +3| """ + < + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/java/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..714362b4ef --- /dev/null +++ b/data/fixtures/scopes/java/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,21 @@ +public class MyClass { + public MyClass(String name, int age) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:22-2:0 + > +0| public class MyClass { +1| public MyClass(String name, int age) {} +2| } + < + + +[#2 Range] = 1:19-1:39 + >--------------------< +1| public MyClass(String name, int age) {} + +[#2 Domain] = 1:18-1:40 + >----------------------< +1| public MyClass(String name, int age) {} diff --git a/data/fixtures/scopes/java/type.argument.formal.constructor.scope b/data/fixtures/scopes/java/type.argument.formal.constructor.scope index 8377e0d303..d84500fc1b 100644 --- a/data/fixtures/scopes/java/type.argument.formal.constructor.scope +++ b/data/fixtures/scopes/java/type.argument.formal.constructor.scope @@ -3,24 +3,36 @@ public class MyClass { } --- -[Content] = 1:25-1:28 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public MyClass(final int value) { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:25-1:28 >---< 1| public MyClass(final int value) { } -[Removal] = 1:25-1:29 +[#2 Removal] = 1:25-1:29 >----< 1| public MyClass(final int value) { } -[Leading delimiter] = 1:24-1:25 +[#2 Leading delimiter] = 1:24-1:25 >-< 1| public MyClass(final int value) { } -[Trailing delimiter] = 1:28-1:29 +[#2 Trailing delimiter] = 1:28-1:29 >-< 1| public MyClass(final int value) { } -[Domain] = 1:19-1:34 +[#2 Domain] = 1:19-1:34 >---------------< 1| public MyClass(final int value) { } -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/java/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..ba89f570c1 --- /dev/null +++ b/data/fixtures/scopes/java/type.argument.formal.method.iteration.scope @@ -0,0 +1,21 @@ +public class MyClass { + public void foo(String name, int age) {} +} +--- + +[#1 Range] = +[#1 Domain] = 0:22-2:0 + > +0| public class MyClass { +1| public void foo(String name, int age) {} +2| } + < + + +[#2 Range] = 1:20-1:40 + >--------------------< +1| public void foo(String name, int age) {} + +[#2 Domain] = 1:19-1:41 + >----------------------< +1| public void foo(String name, int age) {} diff --git a/data/fixtures/scopes/java/type.argument.formal.method.scope b/data/fixtures/scopes/java/type.argument.formal.method.scope index c4bfe46cc6..2648209983 100644 --- a/data/fixtures/scopes/java/type.argument.formal.method.scope +++ b/data/fixtures/scopes/java/type.argument.formal.method.scope @@ -3,47 +3,59 @@ public class MyClass { } --- -[#1 Content] = 1:11-1:15 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >---------------------- +0| public class MyClass { +1| public void foo(final int value) { } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:11-1:15 >----< 1| public void foo(final int value) { } -[#1 Removal] = 1:11-1:16 +[#2 Removal] = 1:11-1:16 >-----< 1| public void foo(final int value) { } -[#1 Leading delimiter] = 1:10-1:11 +[#2 Leading delimiter] = 1:10-1:11 >-< 1| public void foo(final int value) { } -[#1 Trailing delimiter] = 1:15-1:16 +[#2 Trailing delimiter] = 1:15-1:16 >-< 1| public void foo(final int value) { } -[#1 Domain] = 1:4-1:40 +[#2 Domain] = 1:4-1:40 >------------------------------------< 1| public void foo(final int value) { } -[#1 Insertion delimiter] = " " +[#2 Insertion delimiter] = " " -[#2 Content] = 1:26-1:29 +[#3 Content] = 1:26-1:29 >---< 1| public void foo(final int value) { } -[#2 Removal] = 1:26-1:30 +[#3 Removal] = 1:26-1:30 >----< 1| public void foo(final int value) { } -[#2 Leading delimiter] = 1:25-1:26 +[#3 Leading delimiter] = 1:25-1:26 >-< 1| public void foo(final int value) { } -[#2 Trailing delimiter] = 1:29-1:30 +[#3 Trailing delimiter] = 1:29-1:30 >-< 1| public void foo(final int value) { } -[#2 Domain] = 1:20-1:35 +[#3 Domain] = 1:20-1:35 >---------------< 1| public void foo(final int value) { } -[#2 Insertion delimiter] = " " +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.cast.scope b/data/fixtures/scopes/java/type.cast.scope new file mode 100644 index 0000000000..e6cff4d001 --- /dev/null +++ b/data/fixtures/scopes/java/type.cast.scope @@ -0,0 +1,16 @@ +(int)5; +--- + +[Content] = 0:1-0:4 + >---< +0| (int)5; + +[Removal] = 0:0-0:5 + >-----< +0| (int)5; + +[Domain] = 0:0-0:6 + >------< +0| (int)5; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.class.scope b/data/fixtures/scopes/java/type.class.scope new file mode 100644 index 0000000000..f5a6c14b1e --- /dev/null +++ b/data/fixtures/scopes/java/type.class.scope @@ -0,0 +1,10 @@ +public class MyClass { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:24 + >------------------------< +0| public class MyClass { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.enum.scope b/data/fixtures/scopes/java/type.enum.scope new file mode 100644 index 0000000000..eb9f6ef6c5 --- /dev/null +++ b/data/fixtures/scopes/java/type.enum.scope @@ -0,0 +1,15 @@ +public enum Value { + A; +} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >------------------- +0| public enum Value { +1| A; +2| } + -< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.field.scope b/data/fixtures/scopes/java/type.field.scope index 9cdf40e10d..bbab5b7e8f 100644 --- a/data/fixtures/scopes/java/type.field.scope +++ b/data/fixtures/scopes/java/type.field.scope @@ -3,49 +3,61 @@ class MyClass { } --- -[#1 Content] = 1:4-1:17 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| Map foo; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:17 >-------------< 1| Map foo; -[#1 Removal] = 1:4-1:18 +[#2 Removal] = 1:4-1:18 >--------------< 1| Map foo; -[#1 Leading delimiter] = 1:0-1:4 +[#2 Leading delimiter] = 1:0-1:4 >----< 1| Map foo; -[#1 Trailing delimiter] = 1:17-1:18 +[#2 Trailing delimiter] = 1:17-1:18 >-< 1| Map foo; -[#1 Domain] = 1:4-1:22 +[#2 Domain] = 1:4-1:22 >------------------< 1| Map foo; -[#1 Insertion delimiter] = " " +[#2 Insertion delimiter] = " " -[#2 Content] = -[#2 Removal] = -[#2 Domain] = 1:8-1:11 +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:8-1:11 >---< 1| Map foo; -[#2 Insertion delimiter] = " " +[#3 Insertion delimiter] = " " -[#3 Content] = -[#3 Domain] = 1:13-1:16 +[#4 Content] = +[#4 Domain] = 1:13-1:16 >---< 1| Map foo; -[#3 Removal] = 1:12-1:16 +[#4 Removal] = 1:12-1:16 >----< 1| Map foo; -[#3 Leading delimiter] = 1:12-1:13 +[#4 Leading delimiter] = 1:12-1:13 >-< 1| Map foo; -[#3 Insertion delimiter] = " " +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.interface.scope b/data/fixtures/scopes/java/type.interface.scope new file mode 100644 index 0000000000..252521a5af --- /dev/null +++ b/data/fixtures/scopes/java/type.interface.scope @@ -0,0 +1,10 @@ +public interface Value { } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:26 + >--------------------------< +0| public interface Value { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.resource.scope b/data/fixtures/scopes/java/type.resource.scope new file mode 100644 index 0000000000..04bebd6037 --- /dev/null +++ b/data/fixtures/scopes/java/type.resource.scope @@ -0,0 +1,20 @@ +try (PrintWriter writer = create()) { } +--- + +[Content] = 0:5-0:16 + >-----------< +0| try (PrintWriter writer = create()) { } + +[Removal] = 0:5-0:17 + >------------< +0| try (PrintWriter writer = create()) { } + +[Trailing delimiter] = 0:16-0:17 + >-< +0| try (PrintWriter writer = create()) { } + +[Domain] = 0:0-0:39 + >---------------------------------------< +0| try (PrintWriter writer = create()) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.return.scope b/data/fixtures/scopes/java/type.return.scope index a3df4adec0..1e834fba4c 100644 --- a/data/fixtures/scopes/java/type.return.scope +++ b/data/fixtures/scopes/java/type.return.scope @@ -5,27 +5,41 @@ public class MyClass { } --- -[Content] = 1:11-1:14 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >---------------------- +0| public class MyClass { +1| public int myFunk() { +2| return 123; +3| } +4| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:11-1:14 >---< 1| public int myFunk() { -[Removal] = 1:11-1:15 +[#2 Removal] = 1:11-1:15 >----< 1| public int myFunk() { -[Leading delimiter] = 1:10-1:11 +[#2 Leading delimiter] = 1:10-1:11 >-< 1| public int myFunk() { -[Trailing delimiter] = 1:14-1:15 +[#2 Trailing delimiter] = 1:14-1:15 >-< 1| public int myFunk() { -[Domain] = 1:4-3:5 +[#2 Domain] = 1:4-3:5 >--------------------- 1| public int myFunk() { 2| return 123; 3| } -----< -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/type.typeArgument.scope b/data/fixtures/scopes/java/type.typeArgument.scope index 9cdf40e10d..bbab5b7e8f 100644 --- a/data/fixtures/scopes/java/type.typeArgument.scope +++ b/data/fixtures/scopes/java/type.typeArgument.scope @@ -3,49 +3,61 @@ class MyClass { } --- -[#1 Content] = 1:4-1:17 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| class MyClass { +1| Map foo; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:17 >-------------< 1| Map foo; -[#1 Removal] = 1:4-1:18 +[#2 Removal] = 1:4-1:18 >--------------< 1| Map foo; -[#1 Leading delimiter] = 1:0-1:4 +[#2 Leading delimiter] = 1:0-1:4 >----< 1| Map foo; -[#1 Trailing delimiter] = 1:17-1:18 +[#2 Trailing delimiter] = 1:17-1:18 >-< 1| Map foo; -[#1 Domain] = 1:4-1:22 +[#2 Domain] = 1:4-1:22 >------------------< 1| Map foo; -[#1 Insertion delimiter] = " " +[#2 Insertion delimiter] = " " -[#2 Content] = -[#2 Removal] = -[#2 Domain] = 1:8-1:11 +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:8-1:11 >---< 1| Map foo; -[#2 Insertion delimiter] = " " +[#3 Insertion delimiter] = " " -[#3 Content] = -[#3 Domain] = 1:13-1:16 +[#4 Content] = +[#4 Domain] = 1:13-1:16 >---< 1| Map foo; -[#3 Removal] = 1:12-1:16 +[#4 Removal] = 1:12-1:16 >----< 1| Map foo; -[#3 Leading delimiter] = 1:12-1:13 +[#4 Leading delimiter] = 1:12-1:13 >-< 1| Map foo; -[#3 Insertion delimiter] = " " +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/java/value.resource.scope b/data/fixtures/scopes/java/value.resource.scope new file mode 100644 index 0000000000..6f3714c08e --- /dev/null +++ b/data/fixtures/scopes/java/value.resource.scope @@ -0,0 +1,20 @@ +try (PrintWriter writer = create()) { } +--- + +[Content] = 0:26-0:34 + >--------< +0| try (PrintWriter writer = create()) { } + +[Removal] = 0:25-0:34 + >---------< +0| try (PrintWriter writer = create()) { } + +[Leading delimiter] = 0:25-0:26 + >-< +0| try (PrintWriter writer = create()) { } + +[Domain] = 0:0-0:39 + >---------------------------------------< +0| try (PrintWriter writer = create()) { } + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 67a8604bd1..8440f990d1 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -33,9 +33,15 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "branch.switchCase": supported, "branch.switchCase.iteration": supported, "branch.ternary": supported, + "branch.loop": supported, class: supported, + "class.iteration.block": supported, + "class.iteration.document": supported, + className: supported, + "className.iteration.block": supported, + "className.iteration.document": supported, "comment.block": supported, "comment.line": supported, @@ -53,8 +59,13 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { functionCallee: supported, "functionCallee.constructor": supported, + "namedFunction.constructor": supported, + "namedFunction.method": supported, + "namedFunction.method.iteration.class": supported, + "functionName.constructor": supported, "functionName.method": supported, + "functionName.method.iteration.class": supported, "name.argument.formal.constructor": supported, "name.argument.formal.constructor.iteration": supported, @@ -67,29 +78,40 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.foreach": supported, "name.method": supported, "name.variable": supported, - "namedFunction.constructor": supported, - "namedFunction.method": supported, + "name.iteration.document": supported, + "name.iteration.block": supported, + "name.resource": supported, ifStatement: supported, statement: supported, "statement.class": supported, + "statement.iteration.block": supported, + "statement.iteration.document": supported, "string.singleLine": supported, + "string.multiLine": supported, "textFragment.comment.block": supported, "textFragment.comment.line": supported, "textFragment.string.singleLine": supported, - - "type.typeArgument": supported, - "type.typeArgument.iteration": supported, + "textFragment.string.multiLine": supported, "type.argument.formal.constructor": supported, "type.argument.formal.method": supported, + "type.argument.formal.constructor.iteration": supported, + "type.argument.formal.method.iteration": supported, "type.foreach": supported, "type.field": supported, "type.field.iteration": supported, "type.return": supported, "type.variable": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, + "type.resource": supported, + "type.cast": supported, + "type.class": supported, + "type.enum": supported, + "type.interface": supported, "value.assignment": supported, "value.foreach": supported, @@ -97,36 +119,10 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "value.return": supported, "value.return.lambda": supported, "value.variable": supported, + "value.resource": supported, // Unsupported - "class.iteration.block": unsupported, - "class.iteration.document": unsupported, - "className.iteration.block": unsupported, - "className.iteration.document": unsupported, - - "name.iteration.document": unsupported, - "name.iteration.block": 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.iteration.document": 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, @@ -138,12 +134,6 @@ 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, // Not Applicable @@ -155,6 +145,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal.iteration": notApplicable, "name.function": notApplicable, "name.variable.pattern": notApplicable, + "name.resource.iteration": notApplicable, "key.mapPair": notApplicable, "key.mapPair.iteration": notApplicable, @@ -173,10 +164,12 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "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": notApplicable, + "type.resource.iteration": notApplicable, section: notApplicable, "section.iteration.document": notApplicable, @@ -189,8 +182,12 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.element": notApplicable, namedFunction: notApplicable, + "namedFunction.iteration.document": notApplicable, "namedFunction.iteration.block": notApplicable, + "functionName.iteration.document": notApplicable, + "functionName.iteration.block": notApplicable, + pairDelimiter: notApplicable, functionName: notApplicable, map: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index dd454fbccf..59eef32b94 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -706,6 +706,16 @@ export const scopeSupportFacetInfos: Record< scopeType: "type", isIteration: true, }, + "type.resource": { + description: "Type in a 'with' / 'use' / 'using' statement", + scopeType: "type", + }, + "type.resource.iteration": { + description: + "Iteration scope for types in a 'with' / 'use' / 'using' statement", + scopeType: "type", + isIteration: true, + }, "interior.element": { description: "The interior/children of an XML element", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 1e8807b7bb..3941b09149 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -173,6 +173,8 @@ export const scopeSupportFacets = [ "type.class", "type.typeArgument", "type.typeArgument.iteration", + "type.resource", + "type.resource.iteration", "interior.class", "interior.function", diff --git a/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx b/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx index 1026ea64d9..80311cd2e4 100644 --- a/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx +++ b/packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx @@ -27,7 +27,21 @@ export function ScopeSupportForLevel({ }: Props): JSX.Element | null { const [expanded, setExpanded] = useState(expandedProp ?? false); - if (facets.length === 0) { + const facetInfos = facets.map( + (facet): AugmentedFacetInfo => ({ + facet, + ...scopeSupportFacetInfos[facet], + }), + ); + const scopeGroups: Map = groupBy( + facetInfos, + (facetInfo) => serializeScopeType(facetInfo.scopeType), + ); + const scopeTypes = Array.from(scopeGroups.keys()) + .filter((scope) => !scope.startsWith("private.")) + .sort(); + + if (scopeTypes.length === 0) { return null; } @@ -36,18 +50,6 @@ export function ScopeSupportForLevel({ return null; } - const facetInfos = facets.map( - (facet): AugmentedFacetInfo => ({ - facet, - ...scopeSupportFacetInfos[facet], - }), - ); - const scopeGroups: Map = groupBy( - facetInfos, - (facetInfo) => serializeScopeType(facetInfo.scopeType), - ); - const scopeTypes = Array.from(scopeGroups.keys()).sort(); - return (
{description &&

{description}

} diff --git a/queries/java.scm b/queries/java.scm index 3f22a3c6c7..7650d05ee1 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -38,10 +38,57 @@ (field_declaration) ] @statement +[ + (class_declaration) + (interface_declaration) + (enum_declaration) +] @type + (class_declaration name: (_) @name @className ) @class @_.domain +(program) @class.iteration @className.iteration @name.iteration +(program) @statement.iteration + +;;!! class MyClass { } +;;! ^ +(class_body + . + "{" @class.iteration.start.endOf @className.iteration.start.endOf + "}" @class.iteration.end.startOf @className.iteration.end.startOf + . +) + +(class_body + . + "{" @type.iteration.start.endOf @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf + "}" @type.iteration.end.startOf @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf + . +) + +;;!! for (...) { } +;;! ^ +(_ + body: (_ + . + "{" @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 + . + ) +) + ;;!! void myFunk() {} ;;! ^^^^^^^^^^^^^^^^ (method_declaration @@ -69,6 +116,13 @@ (#character-range! @textFragment 1 -1) ) +;;!! """string""" +;;! ^^^^^^^^^^^^ +( + (text_block) @string @textFragment + (#character-range! @textFragment 3 -3) +) + ;;!! // comment ;;! ^^^^^^^^^^ [ @@ -194,7 +248,7 @@ ;;! ------------------------------ (for_statement condition: (_) @condition -) @_.domain +) @branch @_.domain ;;!! while (value) {} ;;! ^^^^^ @@ -202,12 +256,12 @@ (while_statement condition: (_) @condition (#child-range! @condition 0 -1 true true) -) @_.domain +) @branch @_.domain (do_statement condition: (_) @condition (#child-range! @condition 0 -1 true true) -) @_.domain +) @branch @_.domain ;;!! switch (value) {} ;;! ^^^^^ @@ -241,10 +295,10 @@ ;;! ^^^^^^^^^ (formal_parameters . - "(" @name.iteration.start.endOf - ")" @name.iteration.end.startOf + "(" @type.iteration.start.endOf @name.iteration.start.endOf + ")" @type.iteration.end.startOf @name.iteration.end.startOf . -) @name.iteration.domain +) @type.iteration.domain @name.iteration.domain ;;!! Map ;;! ^^^^^^^ ^^^^^^ @@ -287,6 +341,14 @@ type: (_) @type ) @_.domain +;;!! (int)5 +;;! ^^^ +(cast_expression + "(" @type.removal.start + type: (_) @type + ")" @type.removal.end +) @_.domain + ;;!! new test(); ;;! ^^^^^^^^ ;;! ----------- @@ -321,7 +383,7 @@ type: (_) @type name: (_) @name value: (_) @value -) @_.domain +) @branch @_.domain ;;!! int value = 1; ;;! ^ @@ -419,15 +481,6 @@ type: (_) @type ) @_.domain -;;!! class MyClass { } -;;! ^ -(class_body - . - "{" @type.iteration.start.endOf - "}" @type.iteration.end.startOf - . -) - ;;!! public Map foo; ;;! ^^^ ^^^ (type_arguments @@ -482,6 +535,18 @@ ")" @argumentOrParameter.iteration.end.startOf ) @argumentOrParameter.iteration.domain +;;!! try (PrintWriter writer = create()) { } +;;! ^^^^^^^^^^^ ^^^^^ ^^^^^^^^ +(try_with_resources_statement + (resource_specification + (resource + type: (_) @type + name: (_) @name + value: (_) @value + ) + ) +) @_.domain + operator: [ "<" "<<"