### 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.206 diff -u -r1.206 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 9 Jul 2009 10:47:24 -0000 1.206 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 21 Jul 2009 10:55:07 -0000 @@ -20314,5 +20314,88 @@ } +/** + * An inner/member class should not be offered as completion suggestion. + * @throws JavaModelException + */ +public void test270437a() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test270437a.java", + "package test;" + + "public class Test270437a extends Test270437a. {\n" + + " public class Inner {}\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "Test270437a."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + // In the absence of the fix, the results would be as follows, which is wrong: + //"Test270437a.Inner[TYPE_REF]{Inner, test, Ltest.Test270437a$Inner;, null, 39}", + assertResults( + "", //Empty! + requestor.getResults()); +} + +/** + * An inner/member interface should not be offered as completion suggestion. + * @throws JavaModelException + */ +public void test270437b() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test270437b.java", + "package test;" + + "public class Test270437b implements Test270437b. {\n" + + " public interface Inner {}\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "Test270437b."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + // In the absence of the fix, the results would be as follows, which is wrong: + //"Test270437b.Inner[TYPE_REF]{Inner, test, Ltest.Test270437b$Inner;, null, 39}", + assertResults( + "", //Empty! + requestor.getResults()); +} + +/** + * An inner/member interface should not be offered as completion suggestion. + * @throws JavaModelException + */ +public void test270437c() throws JavaModelException { + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test270437c.java", + "package test;" + + "class X extends X.MyClass1. {\n" + + " public class MyClass1 {\n" + + " public class MyClass2 {\n" + + " }\n" + + " }\n" + + "}\n"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "X.MyClass1."; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + // In the absence of the fix, the results would be as follows, which is wrong: + //"X.MyClass1.MyClass2[TYPE_REF]{MyClass2, test, Ltest.X$MyClass1$MyClass2;, null, 39}", + assertResults( + "", //Empty! + requestor.getResults()); +} }