View | Details | Raw Unified | Return to bug 310427 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-7 / +6 lines)
Lines 6001-6014 Link Here
6001
			if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding)
6001
			if (this.assistNodeIsInsideCase && field.type instanceof ArrayBinding)
6002
				continue next;
6002
				continue next;
6003
			
6003
			
6004
			int ptr = this.uninterestingBindingsPtr;
6004
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427
6005
			// Cases where the binding is uninteresting eg. for completion occurring inside a field declaration,
6005
			// Don't propose field which is being declared currently
6006
			// the field binding is uninteresting and shouldn't be proposed.
6006
			// Don't propose fields declared after the current field declaration statement
6007
			while (ptr >= 0) {
6007
			if (this.parser.assistNodeParent instanceof FieldDeclaration) {
6008
				if (this.uninterestingBindings[ptr] == field) {
6008
				FieldDeclaration fieldDeclaration = (FieldDeclaration) this.parser.assistNodeParent;
6009
				if (field.id >= fieldDeclaration.binding.id)
6009
					continue next;
6010
					continue next;
6010
				}
6011
				ptr--;
6012
			}
6011
			}
6013
6012
6014
			boolean prefixRequired = false;
6013
			boolean prefixRequired = false;
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (-7 / +12 lines)
Lines 37-43 Link Here
37
public class CompletionTests extends AbstractJavaModelCompletionTests {
37
public class CompletionTests extends AbstractJavaModelCompletionTests {
38
38
39
static {
39
static {
40
//	TESTS_NAMES = new String[] { "testDeprecationCheck17"};
40
//	TESTS_NAMES = new String[] { "testBug310427c"};
41
}
41
}
42
public static Test suite() {
42
public static Test suite() {
43
	return buildModelTestSuite(CompletionTests.class);
43
	return buildModelTestSuite(CompletionTests.class);
Lines 21346-21371 Link Here
21346
}
21346
}
21347
21347
21348
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427
21348
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=310427
21349
// To verify that we don't get proposals for the field in whose declaration
21349
// To verify that we don't get proposals for fields that have not yet been declared
21350
// content assist is being invoked
21350
// inside a field declaration statement
21351
public void testBug310427a() throws JavaModelException {
21351
public void testBug310427a() throws JavaModelException {
21352
	this.workingCopies = new ICompilationUnit[1];
21352
	this.workingCopies = new ICompilationUnit[1];
21353
	this.workingCopies[0] = getWorkingCopy(
21353
	this.workingCopies[0] = getWorkingCopy(
21354
		"/Completion/src/test/Test.java",
21354
		"/Completion/src/test/Test.java",
21355
		"package test;"+
21355
		"package test;"+
21356
		"public class Test {\n" +
21356
		"public class Test {\n" +
21357
		"	private int myField1;\n" +
21357
		"       int myVar1 = 1;\n" +
21358
		"   private int myField2 = myFiel;\n" +
21358
		"		int myVar2 = 1;\n" +
21359
		"		int myVar3 = myVar;\n" +
21360
		"       int myVar4 = 1;\n" +
21361
		"		int myVar5 = 1;\n" +
21362
		"	}\n" +
21359
		"}\n");
21363
		"}\n");
21360
21364
21361
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21365
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
21362
	String str = this.workingCopies[0].getSource();
21366
	String str = this.workingCopies[0].getSource();
21363
	String completeBehind = "private int myField2 = myFiel";
21367
	String completeBehind = "int myVar3 = myVar";
21364
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21368
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
21365
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21369
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
21366
21370
21367
	assertResults(
21371
	assertResults(
21368
			"myField1[FIELD_REF]{myField1, Ltest.Test;, I, myField1, null, 57}",
21372
			"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" +
21373
			"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) + "}",
21369
			requestor.getResults());
21374
			requestor.getResults());
21370
}
21375
}
21371
21376

Return to bug 310427