summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-12-27 13:02:36 -0800
committerGeorge Fraser <george@fivetran.com>2018-12-27 13:02:36 -0800
commitcbcbbd22afdd867f4f43817dc53df3800814b0ba (patch)
treeedd829d47706136c40025afe222f9ef10094e7e5 /src/test
parent8321c9206bffe676c7794f2404aa69a451e3749b (diff)
downloadjava-language-server-cbcbbd22afdd867f4f43817dc53df3800814b0ba.zip
Fix completion when many static imports are present
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/javacs/CompletionsTest.java5
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java10
-rw-r--r--src/test/test-project/workspace/src/org/javacs/example/AutocompleteClasses.java1
3 files changed, 11 insertions, 5 deletions
diff --git a/src/test/java/org/javacs/CompletionsTest.java b/src/test/java/org/javacs/CompletionsTest.java
index 343a2b8..569a620 100644
--- a/src/test/java/org/javacs/CompletionsTest.java
+++ b/src/test/java/org/javacs/CompletionsTest.java
@@ -452,6 +452,11 @@ public class CompletionsTest extends CompletionsBase {
suggestions = insertText(file, 6, 13);
assertThat(suggestions, hasItems("SomeInnerClass"));
+
+ // List?
+ suggestions = insertText(file, 7, 12);
+
+ assertThat(suggestions, hasItems("List"));
}
@Test
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index a05cf84..ffcbc26 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -128,7 +128,7 @@ public class JavaCompilerServiceTest {
public void completeIdentifiers() {
var uri = resourceUri("/CompleteIdentifiers.java");
var contents = contents("/CompleteIdentifiers.java");
- var ctx = compiler.parseFile(uri, contents).completionPosition(13, 21).get();
+ var ctx = compiler.parseFile(uri, contents).completionContext(13, 21).get();
var focus = compiler.compileFocus(uri, contents, ctx.line, ctx.character);
var found = focus.completeIdentifiers(ctx.inClass, ctx.inMethod, ctx.partialName);
var names = completionNames(found);
@@ -159,7 +159,7 @@ public class JavaCompilerServiceTest {
public void completeMembers() {
var uri = resourceUri("/CompleteMembers.java");
var contents = contents("/CompleteMembers.java");
- var ctx = compiler.parseFile(uri, contents).completionPosition(3, 15).get();
+ var ctx = compiler.parseFile(uri, contents).completionContext(3, 15).get();
var focus = compiler.compileFocus(uri, contents, ctx.line, ctx.character);
var found = focus.completeMembers(false);
var names = completionNames(found);
@@ -172,7 +172,7 @@ public class JavaCompilerServiceTest {
public void completeExpression() {
var uri = resourceUri("/CompleteExpression.java");
var contents = contents("/CompleteExpression.java");
- var ctx = compiler.parseFile(uri, contents).completionPosition(3, 37).get();
+ var ctx = compiler.parseFile(uri, contents).completionContext(3, 37).get();
var focus = compiler.compileFocus(uri, contents, ctx.line, ctx.character);
var found = focus.completeMembers(false);
var names = completionNames(found);
@@ -185,7 +185,7 @@ public class JavaCompilerServiceTest {
public void completeClass() {
var uri = resourceUri("/CompleteClass.java");
var contents = contents("/CompleteClass.java");
- var ctx = compiler.parseFile(uri, contents).completionPosition(3, 23).get();
+ var ctx = compiler.parseFile(uri, contents).completionContext(3, 23).get();
var focus = compiler.compileFocus(uri, contents, ctx.line, ctx.character);
var found = focus.completeMembers(false);
var names = completionNames(found);
@@ -199,7 +199,7 @@ public class JavaCompilerServiceTest {
public void completeImports() {
var uri = resourceUri("/CompleteImports.java");
var contents = contents("/CompleteImports.java");
- var ctx = compiler.parseFile(uri, contents).completionPosition(1, 18).get();
+ var ctx = compiler.parseFile(uri, contents).completionContext(1, 18).get();
var focus = compiler.compileFocus(uri, contents, ctx.line, ctx.character);
var found = focus.completeMembers(false);
var names = completionNames(found);
diff --git a/src/test/test-project/workspace/src/org/javacs/example/AutocompleteClasses.java b/src/test/test-project/workspace/src/org/javacs/example/AutocompleteClasses.java
index bddf9f4..beb8bfc 100644
--- a/src/test/test-project/workspace/src/org/javacs/example/AutocompleteClasses.java
+++ b/src/test/test-project/workspace/src/org/javacs/example/AutocompleteClasses.java
@@ -4,6 +4,7 @@ public class AutocompleteClasses {
public static void test() {
Fix;
Some;
+ Lis;
}
public static class SomeInnerClass {