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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-4 / +7 lines)
Lines 10332-10341 Link Here
10332
			this.currentElement = this.currentElement.parent;
10332
			this.currentElement = this.currentElement.parent;
10333
		} else if(this.currentElement instanceof RecoveredField
10333
		} else if(this.currentElement instanceof RecoveredField
10334
			&& !(this.currentElement instanceof RecoveredInitializer)) {
10334
			&& !(this.currentElement instanceof RecoveredInitializer)) {
10335
10335
			// Do not move focus to parent if we are still inside an array initializer
10336
			int end = ((RecoveredField)this.currentElement).fieldDeclaration.sourceEnd;
10336
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087 
10337
			this.currentElement.updateSourceEndIfNecessary(end);
10337
			if (this.currentElement.bracketBalance <= 0) {
10338
			this.currentElement = this.currentElement.parent;
10338
				int end = ((RecoveredField)this.currentElement).fieldDeclaration.sourceEnd;
10339
				this.currentElement.updateSourceEndIfNecessary(end);
10340
				this.currentElement = this.currentElement.parent;
10341
			}
10339
		}
10342
		}
10340
	}
10343
	}
10341
}
10344
}
(-)src/org/eclipse/jdt/core/tests/compiler/parser/DietRecoveryTest.java (-2 lines)
Lines 4671-4678 Link Here
4671
		"  }\n" +
4671
		"  }\n" +
4672
		"  A foo(int i) {\n" +
4672
		"  A foo(int i) {\n" +
4673
		"  }\n" +
4673
		"  }\n" +
4674
		"  clone() {\n" +
4675
		"  }\n" +
4676
		"  int bar() {\n" +
4674
		"  int bar() {\n" +
4677
		"  }\n" +
4675
		"  }\n" +
4678
		"}\n";
4676
		"}\n";
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests.java (+30 lines)
Lines 20974-20977 Link Here
20974
			"enclosingElement=<anonymous #1> {key=Ltest/TestBug307337$64;} [in obj [in TestBug307337 [in [Working copy] TestBug307337.java [in test [in src [in Completion]]]]]]",
20974
			"enclosingElement=<anonymous #1> {key=Ltest/TestBug307337$64;} [in obj [in TestBug307337 [in [Working copy] TestBug307337.java [in test [in src [in Completion]]]]]]",
20975
			requestor.getContext());
20975
			requestor.getContext());
20976
}
20976
}
20977
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=292087
20978
// To verify that anonymous class in array initializer doesnt cause
20979
// grief to content assist
20980
public void testBug292087() throws JavaModelException {
20981
	this.workingCopies = new ICompilationUnit[1];
20982
	this.workingCopies[0] = getWorkingCopy(
20983
		"/Completion/src/test/Try.java",
20984
		"package test;\n" +
20985
		"public class Try extends Thread{\n" +
20986
		"	public Runnable member[] = { new Runnable (){\n" +
20987
		"		public void run() {}\n" +
20988
		"		}\n" +
20989
		"	};\n" +
20990
		"	Tr\n" +
20991
		"}\n");
20992
20993
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true);
20994
	requestor.allowAllRequiredProposals();
20995
	String str = this.workingCopies[0].getSource();
20996
	String completeBehind = "Tr";
20997
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
20998
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
20999
21000
	assertResults(
21001
			// without the fix no proposals obtained.
21002
			"Tr[POTENTIAL_METHOD_DECLARATION]{Tr, Ltest.Try;, ()V, Tr, null, 14}\n" +
21003
			"transient[KEYWORD]{transient, null, null, transient, null, 14}\n" +
21004
			"Try[TYPE_REF]{Try, test, Ltest.Try;, null, null, 27}",
21005
			requestor.getResults());
21006
}
20977
}
21007
}

Return to bug 292087