### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.156 diff -u -r1.156 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 27 Jun 2007 08:46:42 -0000 1.156 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 27 Jun 2007 09:23:30 -0000 @@ -2942,7 +2942,43 @@ requestor.getResults()); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=102031 +public void testCompletionEmptyTypeName4() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Test {\n" + + " void foo() {\n" + + " new A().call(new /*content assist here*/)\n" + + " }\n" + + "}\n" + + "interface I {\n" + + " void call(TestRunnable r);\n" + + "}\n" + + "class A implements I{\n" + + " public void call(TestRunnable r) {}\n" + + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/TestRunnable.java", + "package test;"+ + "public class TestRunnable {\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "(new "; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + "A[TYPE_REF]{A, test, Ltest.A;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "I[TYPE_REF]{I, test, Ltest.I;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "Test[TYPE_REF]{Test, test, Ltest.Test;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE +R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "TestRunnable[TYPE_REF]{TestRunnable, test, Ltest.TestRunnable;, null, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} /** * Complete at end of file. */ #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.330 diff -u -r1.330 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 27 Jun 2007 08:46:45 -0000 1.330 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 27 Jun 2007 09:23:35 -0000 @@ -8248,6 +8248,11 @@ } private void addExpectedType(TypeBinding type, Scope scope){ if (type == null || !type.isValidBinding()) return; + + // do not add twice the same type + for (int i = 0; i <= this.expectedTypesPtr; i++) { + if (this.expectedTypes[i] == type) return; + } int length = this.expectedTypes.length; if (++this.expectedTypesPtr >= length)