From befec64ce85e15c5450e486e7ce045c6825b9296 Mon Sep 17 00:00:00 2001 From: George Fraser Date: Sun, 24 Jun 2018 10:20:00 -0700 Subject: Test completion in middle of method --- src/test/java/org/javacs/JavaCompilerServiceTest.java | 16 ++++++++++++++++ src/test/resources/CompleteInMiddle.java | 17 +++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/test/resources/CompleteInMiddle.java (limited to 'src/test') diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java index 3a8c344..39989b0 100644 --- a/src/test/java/org/javacs/JavaCompilerServiceTest.java +++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java @@ -105,6 +105,22 @@ public class JavaCompilerServiceTest { assertThat(names, hasItem("CompleteIdentifiers")); } + @Test + public void identifiersInMiddle() { + List found = + compiler.scopeMembers(URI.create("/CompleteInMiddle.java"), contents("/CompleteInMiddle.java"), 13, 21); + List names = elementNames(found); + assertThat(names, hasItem("completeLocal")); + assertThat(names, hasItem("completeParam")); + assertThat(names, hasItem("super")); + assertThat(names, hasItem("this")); + assertThat(names, hasItem("completeOtherMethod")); + assertThat(names, hasItem("completeInnerField")); + assertThat(names, hasItem("completeOuterField")); + assertThat(names, hasItem("completeOuterStatic")); + assertThat(names, hasItem("CompleteInMiddle")); + } + @Test public void completeIdentifiers() { List found = diff --git a/src/test/resources/CompleteInMiddle.java b/src/test/resources/CompleteInMiddle.java new file mode 100644 index 0000000..981e71e --- /dev/null +++ b/src/test/resources/CompleteInMiddle.java @@ -0,0 +1,17 @@ +class CompleteInMiddle { + static int completeOuterStatic; + int completeOuterField; + + class CompleteInnerClass { + int completeInnerField; + + void completeOtherMethod() { + } + + void test(int completeParam) { + int completeLocal = 1; + complete + int localAfter = 2; + } + } +} \ No newline at end of file -- cgit v1.2.3