### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java,v retrieving revision 1.23 diff -u -r1.23 GenericsCompletionParserTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 29 Mar 2006 03:50:24 -0000 1.23 +++ src/org/eclipse/jdt/core/tests/compiler/parser/GenericsCompletionParserTest.java 11 Apr 2006 15:28:13 -0000 @@ -8429,7 +8429,7 @@ expectedReplacedSource, "diet ast"); - expectedCompletionNodeToString = ""; + expectedCompletionNodeToString = "fo()>"; expectedParentNodeToString = ""; completionIdentifier = "fo"; expectedReplacedSource = "foo"; @@ -8438,7 +8438,7 @@ " public Test() {\n" + " }\n" + " void bar() {\n" + - " ;\n" + + " fo()>;\n" + " }\n" + "}\n"; @@ -9073,4 +9073,294 @@ expectedReplacedSource, "diet ast"); } +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 + */ +public void test0206(){ + String str = + "public class Test {\n"+ + " void foo() {\n"+ + " Collections.zzz\n"+ + " }\n"+ + "}\n"; + + String completeBehind = "zzz"; + int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "zzz()>"; + expectedParentNodeToString = ""; + completionIdentifier = "zzz"; + expectedReplacedSource = "zzz"; + expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " zzz()>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 + */ +public void test0207(){ + String str = + "public class Test {\n"+ + " void foo() {\n"+ + " bar().zzz\n"+ + " }\n"+ + "}\n"; + + String completeBehind = "zzz"; + int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "zzz()>"; + expectedParentNodeToString = ""; + completionIdentifier = "zzz"; + expectedReplacedSource = "zzz"; + expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " zzz()>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 + */ +public void test0208(){ + String str = + "public class Test {\n"+ + " void foo() {\n"+ + " int.zzz\n"+ + " }\n"+ + "}\n"; + + String completeBehind = "zzz"; + int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = ""; + expectedParentNodeToString = ""; + completionIdentifier = "zzz"; + expectedReplacedSource = "zzz"; + expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " ;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 + */ +public void test0209(){ + String str = + "public class Test {\n"+ + " void foo() {\n"+ + " this.zzz\n"+ + " }\n"+ + "}\n"; + + String completeBehind = "zzz"; + int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "zzz()>"; + expectedParentNodeToString = ""; + completionIdentifier = "zzz"; + expectedReplacedSource = "zzz"; + expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " zzz()>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} +/* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 + */ +public void test0210(){ + String str = + "public class Test {\n"+ + " void foo() {\n"+ + " super.zzz\n"+ + " }\n"+ + "}\n"; + + String completeBehind = "zzz"; + int cursorLocation = str.indexOf("zzz") + completeBehind.length() - 1; + String expectedCompletionNodeToString = ""; + String expectedParentNodeToString = ""; + String completionIdentifier = ""; + String expectedReplacedSource = ""; + String expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " }\n" + + "}\n"; + + checkDietParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "diet ast"); + + expectedCompletionNodeToString = "zzz()>"; + expectedParentNodeToString = ""; + completionIdentifier = "zzz"; + expectedReplacedSource = "zzz"; + expectedUnitDisplayString = + "public class Test {\n" + + " public Test() {\n" + + " }\n" + + " void foo() {\n" + + " zzz()>;\n" + + " }\n" + + "}\n"; + + checkMethodParse( + str.toCharArray(), + cursorLocation, + expectedCompletionNodeToString, + expectedParentNodeToString, + expectedUnitDisplayString, + completionIdentifier, + expectedReplacedSource, + "full ast"); +} } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v retrieving revision 1.63 diff -u -r1.63 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 7 Apr 2006 08:20:43 -0000 1.63 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 11 Apr 2006 15:28:23 -0000 @@ -8196,4 +8196,428 @@ "Test270[TYPE_REF]{Test270, test, Ltest.Test270;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXPECTED_TYPE + R_UNQUALIFIED + R_EXACT_NAME + R_NON_RESTRICTED) + "}", requestor.getResults()); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0271() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo() {\n"+ + " TestCollections.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0272() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo(TestCollections t) {\n"+ + " t.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "zzz1[METHOD_REF]{zzz1(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz1, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0273() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " TestCollections bar() {\n"+ + " return null;\n"+ + " }\n"+ + " void foo() {\n"+ + " bar().zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}\n" + + "zzz1[METHOD_REF]{zzz1(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz1, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_STATIC + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0274() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo() {\n"+ + " int.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0275() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo(int t) {\n"+ + " t.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0276() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " int bar() {\n"+ + " return 0;\n"+ + " }\n"+ + " void foo() {\n"+ + " bar().zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0277() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo(TestCollections[] o) {\n"+ + " o.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0278() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + " void foo(TestCollections[] o) {\n"+ + " this.zzz\n"+ + " }\n"+ + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.Test;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0279() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test extends TestCollections {\n"+ + " void foo() {\n"+ + " super.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0280() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo() {\n"+ + " TestCollections.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0281() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " void foo() {\n"+ + " TestCollections.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestCollections.java", + "package test;\n"+ + "public class TestCollections {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.TestCollections;, (TT;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0282() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + " void foo() {\n"+ + " this.zzz\n"+ + " }\n"+ + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0283() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + " void foo() {\n"+ + " this.zzz\n"+ + " }\n"+ + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "", + requestor.getResults()); +} +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=106450 +public void test0284() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;\n"+ + "public class Test {\n"+ + " public void zzz1(T t) {}\n"+ + " public static void zzz2(T t) {}\n"+ + " void foo() {\n"+ + " this.zzz\n"+ + " }\n"+ + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/Test2.java", + "package test;\n"+ + "public class Test2 {\n"+ + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + + String str = this.workingCopies[0].getSource(); + String completeBehind = "zzz"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "zzz2[METHOD_REF]{zzz2(), Ltest.Test;, (Ljava.lang.Object;)V, zzz2, (t), " + (R_DEFAULT + R_INTERESTING + R_CASE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} } #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java,v retrieving revision 1.154 diff -u -r1.154 CompletionParser.java --- codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 28 Mar 2006 20:29:57 -0000 1.154 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionParser.java 11 Apr 2006 15:28:32 -0000 @@ -109,6 +109,8 @@ static final int LPAREN_NOT_CONSUMED = 1; static final int LPAREN_CONSUMED = 2; + // K_PARAMETERIZED_METHOD_INVOCATION arguments + static final int INSIDE_NAME = 1; // the type of the current invocation (one of the invocation type constants) int invocationType; @@ -856,8 +858,10 @@ } break nextElement; case K_PARAMETERIZED_METHOD_INVOCATION : - currentElement = currentElement.add((TypeReference)node, 0); - break nextElement; + if(topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER, 1) == 0) { + currentElement = currentElement.add((TypeReference)node, 0); + break nextElement; + } } if(info == LESS && node instanceof TypeReference) { if(this.identifierLengthPtr > -1 && this.identifierLengthStack[this.identifierLengthPtr]!= 0) { @@ -1321,6 +1325,80 @@ this.isOrphanCompletionNode = true; return true; } +private boolean checkParemeterizedMethodName() { + if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION && + topKnownElementInfo(COMPLETION_OR_ASSIST_PARSER) == INSIDE_NAME) { + if(this.identifierLengthPtr > -1 && this.genericsLengthPtr > -1 && this.genericsIdentifiersLengthPtr == -1) { + CompletionOnMessageSendName m = null; + switch (this.invocationType) { + case EXPLICIT_RECEIVER: + case NO_RECEIVER: // this case occurs with 'bar().foo' + if(this.expressionPtr > -1 && this.expressionLengthStack[this.expressionLengthPtr] == 1) { + char[] selector = this.identifierStack[this.identifierPtr]; + long position = this.identifierPositionStack[identifierPtr--]; + this.identifierLengthPtr--; + int end = (int) position; + int start = (int) (position >>> 32); + m = new CompletionOnMessageSendName(selector, start, end); + + // handle type arguments + int length = this.genericsLengthStack[this.genericsLengthPtr--]; + this.genericsPtr -= length; + System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length); + intPtr--; + + m.receiver = this.expressionStack[this.expressionPtr--]; + this.expressionLengthPtr--; + } + break; + case NAME_RECEIVER: + if(this.identifierPtr > 0) { + char[] selector = this.identifierStack[this.identifierPtr]; + long position = this.identifierPositionStack[identifierPtr--]; + this.identifierLengthPtr--; + int end = (int) position; + int start = (int) (position >>> 32); + m = new CompletionOnMessageSendName(selector, start, end); + + // handle type arguments + int length = this.genericsLengthStack[this.genericsLengthPtr--]; + this.genericsPtr -= length; + System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length); + intPtr--; + + m.receiver = getUnspecifiedReference(); + } + break; + case SUPER_RECEIVER: + char[] selector = this.identifierStack[this.identifierPtr]; + long position = this.identifierPositionStack[identifierPtr--]; + this.identifierLengthPtr--; + int end = (int) position; + int start = (int) (position >>> 32); + m = new CompletionOnMessageSendName(selector, start, end); + + // handle type arguments + int length = this.genericsLengthStack[this.genericsLengthPtr--]; + this.genericsPtr -= length; + System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length); + intPtr--; + + m.receiver = new SuperReference(start, end); + break; + } + + if(m != null) { + pushOnExpressionStack(m); + + this.assistNode = m; + this.lastCheckPoint = this.assistNode.sourceEnd + 1; + this.isOrphanCompletionNode = true; + return true; + } + } + } + return false; +} private boolean checkParemeterizedType() { if(this.identifierLengthPtr > -1 && this.genericsLengthPtr > -1 && this.genericsIdentifiersLengthPtr > -1) { int length = this.identifierLengthStack[this.identifierLengthPtr]; @@ -1557,6 +1635,7 @@ if (checkInvocation()) return; if (checkParemeterizedType()) return; + if (checkParemeterizedMethodName()) return; if (checkLabelStatement()) return; if (checkNameCompletion()) return; } @@ -2432,7 +2511,12 @@ if (isInsideMethod() || isInsideFieldInitialization() || isInsideAnnotation()) { switch(token) { case TokenNameLPAREN: - popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET); + if(previous == TokenNameIdentifier && + topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION) { + popElement(K_PARAMETERIZED_METHOD_INVOCATION); + } else { + popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET); + } break; case TokenNameLBRACE: popElement(K_BETWEEN_NEW_AND_LEFT_BRACKET); @@ -2864,6 +2948,7 @@ popElement(K_BINARY_OPERATOR); if(topKnownElementKind(COMPLETION_OR_ASSIST_PARSER) == K_PARAMETERIZED_METHOD_INVOCATION) { popElement(K_PARAMETERIZED_METHOD_INVOCATION); + pushOnElementStack(K_PARAMETERIZED_METHOD_INVOCATION, INSIDE_NAME); } else { popElement(K_PARAMETERIZED_ALLOCATION); } Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.283 diff -u -r1.283 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 7 Apr 2006 08:20:29 -0000 1.283 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 11 Apr 2006 15:28:29 -0000 @@ -743,7 +743,7 @@ SourceTypeBinding enclosingType = scope.enclosingSourceType(); if (!enclosingType.isAnnotationType()) { if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) { - findMethods(this.completionToken,null,enclosingType,scope,new ObjectVector(),false,false,true,null,null,false,false,true); + findMethods(this.completionToken,null,null,enclosingType,scope,new ObjectVector(),false,false,true,null,null,false,false,true); } if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { proposeNewMethod(this.completionToken, enclosingType); @@ -765,7 +765,7 @@ SourceTypeBinding enclosingType = scope.enclosingSourceType(); if (!enclosingType.isAnnotationType()) { if (!this.requestor.isIgnored(CompletionProposal.METHOD_DECLARATION)) { - findMethods(this.completionToken,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false,false,true); + findMethods(this.completionToken,null,null,scope.enclosingSourceType(),scope,new ObjectVector(),false,false,true,null,null,false,false,true); } if (!this.requestor.isIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION)) { proposeNewMethod(this.completionToken, scope.enclosingSourceType()); @@ -928,6 +928,7 @@ findMethods( this.completionToken, null, + null, receiverType, scope, new ObjectVector(), @@ -1013,6 +1014,7 @@ } else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { findMethods( this.completionToken, + null, argTypes, (ReferenceBinding)((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd), scope, @@ -1237,6 +1239,43 @@ this.findLabels(this.completionToken, label.possibleLabels); } + } else if(astNode instanceof CompletionOnMessageSendName) { + if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { + CompletionOnMessageSendName messageSend = (CompletionOnMessageSendName) astNode; + + this.insideQualifiedReference = true; + this.completionToken = messageSend.selector; + boolean onlyStatic = false; + TypeBinding receiverType = null; + if(qualifiedBinding instanceof VariableBinding) { + receiverType = ((VariableBinding)qualifiedBinding).type; + } else if(qualifiedBinding instanceof MethodBinding) { + receiverType = ((MethodBinding)qualifiedBinding).returnType; + } else if(qualifiedBinding instanceof ReferenceBinding && !(qualifiedBinding instanceof TypeVariableBinding)) { + onlyStatic = true; + receiverType = (TypeBinding)qualifiedBinding; + } + if(receiverType != null && receiverType instanceof ReferenceBinding) { + TypeBinding[] typeArgTypes = computeTypesIfCorrect(messageSend.typeArguments); + if(typeArgTypes != null) { + this.findMethods( + this.completionToken, + typeArgTypes, + null, + (ReferenceBinding)receiverType.capture(scope, messageSend.receiver.sourceEnd), + scope, + new ObjectVector(), + onlyStatic, + false, + false, + messageSend, + scope, + false, + false, + true); + } + } + } // Completion on Javadoc nodes } else if ((astNode.bits & ASTNode.InsideJavadoc) != 0) { if (astNode instanceof CompletionOnJavadocSingleTypeReference) { @@ -1312,6 +1351,7 @@ || !this.requestor.isIgnored(CompletionProposal.JAVADOC_METHOD_REF)) { findMethods(this.completionToken, null, + null, receiverType, scope, new ObjectVector(), @@ -1357,6 +1397,7 @@ } } else if (!this.requestor.isIgnored(CompletionProposal.METHOD_REF)) { findMethods(this.completionToken, + null, argTypes, (ReferenceBinding) ((ReferenceBinding) qualifiedBinding).capture(scope, messageSend.receiver.sourceEnd), scope, @@ -1795,6 +1836,18 @@ return argTypes; } + private TypeBinding[] computeTypesIfCorrect(Expression[] arguments) { + if (arguments == null) return null; + int argsLength = arguments.length; + TypeBinding[] argTypes = new TypeBinding[argsLength]; + for (int a = argsLength; --a >= 0;) { + TypeBinding typeBinding = arguments[a].resolvedType; + if(typeBinding == null || !typeBinding.isValidBinding()) return null; + argTypes[a] = typeBinding; + } + return argTypes; + } + private void findAnnotationAttributes(char[] token, MemberValuePair[] attributesFound, ReferenceBinding annotation) { MethodBinding[] methods = annotation.availableMethods(); nextAttribute: for (int i = 0; i < methods.length; i++) { @@ -2793,6 +2846,7 @@ findMethods( token, null, + null, (ReferenceBinding) receiverType, scope, methodsFound, @@ -3620,6 +3674,7 @@ private void findInterfacesMethods( char[] selector, + TypeBinding[] typeArgTypes, TypeBinding[] argTypes, ReferenceBinding receiverType, ReferenceBinding[] itsInterfaces, @@ -3668,6 +3723,7 @@ findLocalMethods( selector, + typeArgTypes, argTypes, methods, scope, @@ -3739,6 +3795,7 @@ SourceTypeBinding enclosingType = classScope.referenceContext.binding; findMethods( token, + null, argTypes, enclosingType, classScope, @@ -3764,6 +3821,7 @@ // Helper method for findMethods(char[], TypeBinding[], ReferenceBinding, Scope, ObjectVector, boolean, boolean, boolean) private void findLocalMethods( char[] methodName, + TypeBinding[] typeArgTypes, TypeBinding[] argTypes, MethodBinding[] methods, Scope scope, @@ -3782,6 +3840,7 @@ // No visibility checks can be performed without the scope & invocationSite int methodLength = methodName.length; + int minTypeArgLength = typeArgTypes == null ? 0 : typeArgTypes.length; int minArgLength = argTypes == null ? 0 : argTypes.length; next : for (int f = methods.length; --f >= 0;) { @@ -3822,6 +3881,14 @@ continue next; } } + + if (minTypeArgLength != 0 && minTypeArgLength != method.typeVariables.length) + continue next; + + if (minTypeArgLength != 0) { + method = new ParameterizedGenericMethodBinding(method, typeArgTypes, scope.environment()); + } + if (minArgLength > method.parameters.length) continue next; @@ -4586,6 +4653,7 @@ private void findMethods( char[] selector, + TypeBinding[] typeArgTypes, TypeBinding[] argTypes, ReferenceBinding receiverType, Scope scope, @@ -4621,6 +4689,7 @@ if (isCompletingDeclaration) { findInterfacesMethods( selector, + typeArgTypes, argTypes, receiverType, currentType.superInterfaces(), @@ -4637,6 +4706,7 @@ } else { findInterfacesMethods( selector, + typeArgTypes, argTypes, receiverType, new ReferenceBinding[]{currentType}, @@ -4657,6 +4727,7 @@ if (isCompletingDeclaration){ findInterfacesMethods( selector, + typeArgTypes, argTypes, receiverType, currentType.superInterfaces(), @@ -4691,6 +4762,7 @@ } else{ findLocalMethods( selector, + typeArgTypes, argTypes, methods, scope, @@ -4709,6 +4781,7 @@ if (notInJavadoc && hasPotentialDefaultAbstractMethods && (currentType.isAbstract() || currentType.isTypeVariable())){ findInterfacesMethods( selector, + typeArgTypes, argTypes, receiverType, currentType.superInterfaces(), @@ -5561,6 +5634,7 @@ findMethods( token, null, + null, enclosingType, classScope, methodsFound, @@ -5610,6 +5684,7 @@ findMethods( token, null, + null, (ReferenceBinding)binding, scope, methodsFound, Index: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSendName.java =================================================================== RCS file: codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSendName.java diff -N codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSendName.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnMessageSendName.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.jdt.internal.codeassist.complete; + +import org.eclipse.jdt.internal.compiler.ast.MessageSend; +import org.eclipse.jdt.internal.compiler.ast.NameReference; +import org.eclipse.jdt.internal.compiler.lookup.BlockScope; +import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; + +public class CompletionOnMessageSendName extends MessageSend { + public CompletionOnMessageSendName(char[] selector, int start, int end) { + super(); + this.selector = selector; + this.sourceStart = start; + this.sourceEnd = end; + this.nameSourcePosition = end; + } + + public TypeBinding resolveType(BlockScope scope) { + + if (receiver.isImplicitThis()) + throw new CompletionNodeFound(); + + this.actualReceiverType = receiver.resolveType(scope); + if (this.actualReceiverType == null || this.actualReceiverType.isBaseType() || this.actualReceiverType.isArrayType()) + throw new CompletionNodeFound(); + + // resolve type arguments + if (this.typeArguments != null) { + int length = this.typeArguments.length; + this.genericTypeArguments = new TypeBinding[length]; + for (int i = 0; i < length; i++) { + this.genericTypeArguments[i] = this.typeArguments[i].resolveType(scope, true /* check bounds*/); + } + } + + if(this.receiver instanceof NameReference) { + throw new CompletionNodeFound(this, ((NameReference)this.receiver).binding, scope); + } else if(this.receiver instanceof MessageSend) { + throw new CompletionNodeFound(this, ((MessageSend)this.receiver).binding, scope); + } + throw new CompletionNodeFound(this, this.actualReceiverType, scope); + } + + public StringBuffer printExpression(int indent, StringBuffer output) { + + output.append("'); + } + output.append(selector).append('('); + return output.append(")>"); //$NON-NLS-1$ + } +}