### Eclipse Workspace Patch 1.0 #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.416 diff -u -r1.416 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 22 Jul 2010 04:25:46 -0000 1.416 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 9 Aug 2010 10:17:56 -0000 @@ -6001,14 +6001,13 @@ if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding) continue next; - int ptr = this.uninterestingBindingsPtr; - // Cases where the binding is uninteresting eg. for completion occurring inside a field declaration, - // the field binding is uninteresting and shouldn't be proposed. - while (ptr >= 0) { - if (this.uninterestingBindings[ptr] == field) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427 + // Don't propose field which is being declared currently + // Don't propose fields declared after the current field declaration statement + if (this.parser.assistNodeParent instanceof FieldDeclaration) { + FieldDeclaration fieldDeclaration = (FieldDeclaration) this.parser.assistNodeParent; + if (field.id >= fieldDeclaration.binding.id) continue next; - } - ptr--; } boolean prefixRequired = false; #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.222 diff -u -r1.222 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 7 Jul 2010 13:19:15 -0000 1.222 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 9 Aug 2010 10:19:01 -0000 @@ -37,7 +37,7 @@ public class CompletionTests extends AbstractJavaModelCompletionTests { static { -// TESTS_NAMES = new String[] { "testDeprecationCheck17"}; +// TESTS_NAMES = new String[] { "testBug310427c"}; } public static Test suite() { return buildModelTestSuite(CompletionTests.class); @@ -21346,26 +21346,31 @@ } // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427 -// To verify that we don't get proposals for the field in whose declaration -// content assist is being invoked +// To verify that we don't get proposals for fields that have not yet been declared +// inside a field declaration statement public void testBug310427a() throws JavaModelException { this.workingCopies = new ICompilationUnit[1]; this.workingCopies[0] = getWorkingCopy( "/Completion/src/test/Test.java", "package test;"+ "public class Test {\n" + - " private int myField1;\n" + - " private int myField2 = myFiel;\n" + + " int myVar1 = 1;\n" + + " int myVar2 = 1;\n" + + " int myVar3 = myVar;\n" + + " int myVar4 = 1;\n" + + " int myVar5 = 1;\n" + + " }\n" + "}\n"); CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); String str = this.workingCopies[0].getSource(); - String completeBehind = "private int myField2 = myFiel"; + String completeBehind = "int myVar3 = myVar"; int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); assertResults( - "myField1[FIELD_REF]{myField1, Ltest.Test;, I, myField1, null, 57}", + "myVar1[FIELD_REF]{myVar1, Ltest.Test;, I, myVar1, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}\n" + + "myVar2[FIELD_REF]{myVar2, Ltest.Test;, I, myVar2, null, " + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED + R_EXACT_EXPECTED_TYPE) + "}", requestor.getResults()); }