Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorssankaran2014-10-23 12:07:44 +0000
committerssankaran2014-10-23 13:30:59 +0000
commite060e0428f7f92647e77ad8da2c7818eb4c4e3a7 (patch)
tree89b4b8533a22bf7d42adf459dc027ffbc069dbf5 /org.eclipse.jdt.core.tests.compiler
parent027433d18c80815de3076b7fd489422a48401f1a (diff)
downloadeclipse.jdt.core-e060e0428f7f92647e77ad8da2c7818eb4c4e3a7.tar.gz
eclipse.jdt.core-e060e0428f7f92647e77ad8da2c7818eb4c4e3a7.tar.xz
eclipse.jdt.core-e060e0428f7f92647e77ad8da2c7818eb4c4e3a7.zip
Bug 446765 - [1.8][content assist] Completion does not work with both
lambdas and anonymous classes in the picture
Diffstat (limited to 'org.eclipse.jdt.core.tests.compiler')
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest18.java242
1 files changed, 226 insertions, 16 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest18.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest18.java
index bba49fa8bc..a1cdbef2df 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest18.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/CompletionParserTest18.java
@@ -1710,7 +1710,6 @@ public void test430656() {
"diet ast");
}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=438952, [1.8][content assist] StackOverflowError at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.traverse(SingleTypeReference.java:108)
-// FIXME: Recovered parse tree isn't quite correct, but is harmless.
public void test438952() {
String string =
"import java.util.function.Supplier;\n" +
@@ -1738,22 +1737,7 @@ public void test438952() {
"class SO {\n" +
" {\n" +
" int Supplier;\n" +
- " new SO() {\n" +
- " {\n" +
- " }\n" +
- " void test() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " void test() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
- " };\n" +
" m6 = () -> new SO() {\n" +
- " {\n" +
- " }\n" +
- " void test() {\n" +
- " <CompleteOnName:>;\n" +
- " }\n" +
" void test() {\n" +
" <CompleteOnName:>;\n" +
" }\n" +
@@ -2068,4 +2052,230 @@ public void test430667d() {
expectedReplacedSource,
"diet ast");
}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=446765,
+public void test446765() {
+ String string =
+ "class Stepper<T> {\n" +
+ " public interface Step<T> {\n" +
+ " void run();\n" +
+ " }\n" +
+ " public Stepper(Handler<AsyncResult<T>> handler) {}\n" +
+ "\n" +
+ " @SafeVarargs\n" +
+ " public final void run(Step<T> ... steps) {}\n" +
+ "}\n" +
+ "interface AsyncResult<T> {}\n" +
+ "interface Handler<E> {\n" +
+ " void handle(E event);\n" +
+ "}\n" +
+ "class Z {\n" +
+ " void foo() {}\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void foo(Z z);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " void request(I i) {}\n" +
+ "}\n" +
+ "public class X {\n" +
+ " void test() {\n" +
+ " new Stepper<Void>(r -> {}) {\n" +
+ " private void step1() {\n" +
+ " Y y = new Y();\n" +
+ " y.request(response -> {\n" +
+ " if (response.)\n" +
+ " });\n" +
+ " }\n" +
+ " }.run(); \n" +
+ " } \n" +
+ "}\n";
+
+ String completeBehind = "response.";
+ int cursorLocation = string.indexOf(completeBehind) + completeBehind.length() - 1;
+
+ String expectedCompletionNodeToString = "<CompleteOnName:response.>";
+ String expectedParentNodeToString = "if (<CompleteOnName:response.>)\n" +
+ " ;";
+ String completionIdentifier = "";
+ String expectedReplacedSource = "response.";
+ String expectedUnitDisplayString =
+ "class Stepper<T> {\n" +
+ " public interface Step<T> {\n" +
+ " void run();\n" +
+ " }\n" +
+ " public Stepper(Handler<AsyncResult<T>> handler) {\n" +
+ " }\n" +
+ " public final @SafeVarargs void run(Step<T>... steps) {\n" +
+ " }\n" +
+ "}\n" +
+ "interface AsyncResult<T> {\n" +
+ "}\n" +
+ "interface Handler<E> {\n" +
+ " void handle(E event);\n" +
+ "}\n" +
+ "class Z {\n" +
+ " Z() {\n" +
+ " }\n" +
+ " void foo() {\n" +
+ " }\n" +
+ "}\n" +
+ "interface I {\n" +
+ " void foo(Z z);\n" +
+ "}\n" +
+ "class Y {\n" +
+ " Y() {\n" +
+ " }\n" +
+ " void request(I i) {\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void test() {\n" +
+ " new Stepper<Void>((<no type> r) -> {\n" +
+ "}) {\n" +
+ " private void step1() {\n" +
+ " Y y;\n" +
+ " y.request((<no type> response) -> {\n" +
+ " <CompleteOnName:response.>;\n" +
+ "});\n" +
+ " }\n" +
+ " };\n" +
+ " }\n" +
+ "}\n";
+
+ checkMethodParse(
+ string.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ "diet ast");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=428735, [1.8][assist] Missing completion proposals inside lambda body expression - other than first token
+public void test428735h() {
+ String string =
+ "import java.util.List;\n" +
+ "class Person {\n" +
+ " String getLastName() { return null; }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " void test2(List<Person> people) {\n" +
+ " people.sort((x,y) -> {\n" +
+ " if (true) return \"\" + x.get); \n" +
+ " else return \"\";\n" +
+ " }\n" +
+ "}\n";
+
+ String completeBehind = "x.get";
+ int cursorLocation = string.indexOf(completeBehind) + completeBehind.length() - 1;
+
+ String expectedCompletionNodeToString = "<CompleteOnName:x.get>";
+ String expectedParentNodeToString = "(\"\" + <CompleteOnName:x.get>)";
+ String completionIdentifier = "get";
+ String expectedReplacedSource = "x.get";
+ String expectedUnitDisplayString =
+ "import java.util.List;\n" +
+ "class Person {\n" +
+ " Person() {\n" +
+ " }\n" +
+ " String getLastName() {\n" +
+ " }\n" +
+ "}\n" +
+ "public class X {\n" +
+ " public X() {\n" +
+ " }\n" +
+ " void test2(List<Person> people) {\n" +
+ " people.sort((<no type> x, <no type> y) -> {\n" +
+ " if (true)\n" +
+ " return (\"\" + <CompleteOnName:x.get>);\n" +
+ " ;\n" +
+ " return \"\";\n" +
+ "});\n" +
+ " }\n" +
+ "}\n";
+
+ checkMethodParse(
+ string.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ "diet ast");
+}
+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=422468, [1.8][assist] Code assist issues with type elided lambda parameters
+public void test422468() { // computing visible elements in lambda scope.
+ String string =
+ "interface I {\n" +
+ " void foo(X x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static X xField;\n" +
+ " static X goo(String s) {\n" +
+ " return null;\n" +
+ " }\n" +
+ " static void goo(I i) {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X xLocal = null;\n" +
+ " args = null;\n" +
+ " if (args != null) {\n" +
+ " xField = null;\n" +
+ " else \n" +
+ " xField = null;\n" +
+ " while (true);\n" +
+ " goo((xyz) -> {\n" +
+ " X xLambdaLocal = null;\n" +
+ " System.out.println(xyz.)\n" +
+ " });\n" +
+ " }\n" +
+ "}\n";
+ String completeBehind = "xyz.";
+ int cursorLocation = string.indexOf(completeBehind) + completeBehind.length() - 1;
+
+ String expectedCompletionNodeToString = "<CompleteOnName:xyz.>";
+ String expectedParentNodeToString = "System.out.println(<CompleteOnName:xyz.>)";
+ String completionIdentifier = "";
+ String expectedReplacedSource = "xyz.";
+ String expectedUnitDisplayString =
+ "interface I {\n" +
+ " void foo(X x);\n" +
+ "}\n" +
+ "public class X {\n" +
+ " static X xField;\n" +
+ " public X() {\n" +
+ " }\n" +
+ " <clinit>() {\n" +
+ " }\n" +
+ " static X goo(String s) {\n" +
+ " }\n" +
+ " static void goo(I i) {\n" +
+ " }\n" +
+ " public static void main(String[] args) {\n" +
+ " X xLocal;\n" +
+ " {\n" +
+ " {\n" +
+ " goo((<no type> xyz) -> {\n" +
+ " X xLambdaLocal;\n" +
+ " System.out.println(<CompleteOnName:xyz.>);\n" +
+ "});\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n";
+
+ checkMethodParse(
+ string.toCharArray(),
+ cursorLocation,
+ expectedCompletionNodeToString,
+ expectedParentNodeToString,
+ expectedUnitDisplayString,
+ completionIdentifier,
+ expectedReplacedSource,
+ "diet ast");
+}
}

Back to the top