### 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.203 diff -u -r1.203 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 7 May 2009 08:49:30 -0000 1.203 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 3 Jun 2009 12:43:11 -0000 @@ -20102,4 +20102,61 @@ requestor.getResults()); } +public void test276526a() throws JavaModelException { + // This test is to ensure that an existing super interface is not offered as a completion choice, + // when all of them are in the same compilation unit. + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test276526a.java", + "package test;\n" + + "interface IFoo {}\n" + + "interface IBar {}\n" + + "class Foo implements IFoo, test. {}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "test."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + // In the absence of the fix, it would have been: + // "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 39}\n" + + // "IFoo[TYPE_REF]{IFoo, test, Ltest.IFoo;, null, 39}" + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + "IBar[TYPE_REF]{IBar, test, Ltest.IBar;, null, 39}", + requestor.getResults()); +} + +public void test276526b() throws JavaModelException { + // This test is to ensure that an existing super interface is not offered as a completion choice, + // when they are in different compilation units. + this.workingCopies = new ICompilationUnit[3]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test276526b1.java", + "package test;\n" + + "public class TestClazz implements Interface1, test. {}"); + + this.workingCopies[1] = getWorkingCopy( + "/Completion/src/test/Test276526b2.java", + "package test;\n" + + "public interface Interface1 {}"); + + this.workingCopies[2] = getWorkingCopy( + "/Completion/src/test/Test276526b3.java", + "package test;\n" + + "public interface Interface2 {}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "test."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + // In the absence of the fix, it would also complete to Interface1: + //"Interface1[TYPE_REF]{Interface1, test, Ltest.Interface1;, null, 39}\n"+ + "Interface2[TYPE_REF]{Interface2, test, Ltest.Interface2;, null, 39}", + requestor.getResults()); +} + }