View | Details | Raw Unified | Return to bug 208013
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/TypeBinding.java (-1 / +3 lines)
Lines 554-560 Link Here
554
			// must use getElementAt(...) as there is no back pointer to the defining method (scope is null after resolution has ended)
554
			// must use getElementAt(...) as there is no back pointer to the defining method (scope is null after resolution has ended)
555
			try {
555
			try {
556
				int sourceStart = ((LocalTypeBinding) referenceBinding).sourceStart;
556
				int sourceStart = ((LocalTypeBinding) referenceBinding).sourceStart;
557
				return (JavaElement) cu.getElementAt(sourceStart);
557
				IJavaElement element =cu.getElementAt(sourceStart);
558
				// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=208013
559
				return (JavaElement) element.getAncestor(IJavaElement.TYPE);
558
			} catch (JavaModelException e) {
560
			} catch (JavaModelException e) {
559
				// does not exist
561
				// does not exist
560
				return null;
562
				return null;
(-)src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java (+29 lines)
Lines 1225-1230 Link Here
1225
	}
1225
	}
1226
1226
1227
	/*
1227
	/*
1228
	 * Ensures that no ClassCastException is thrown if the method is in an anonymous 
1229
	 * which is inside the initializer of another anonymous.
1230
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=208013)
1231
	 */
1232
	public void testMethod11() throws JavaModelException {
1233
		ASTNode node = buildAST(
1234
			"public class X {\n" + 
1235
			"  public void foo() {\n" + 
1236
			"    new Object() {\n" +
1237
			"      Object o;\n" +
1238
			"      {\n"+
1239
			"        new Object() {\n" + 
1240
			"          /*start*/void bar() {\n" +
1241
			"          }/*end*/\n" +
1242
			"		  };\n" + 
1243
			"      }\n" +
1244
			"    };\n"+
1245
			"  }\n" + 
1246
			"}"
1247
		);
1248
		IBinding binding = ((MethodDeclaration) node).resolveBinding();
1249
		IJavaElement element = binding.getJavaElement();
1250
		assertElementEquals(
1251
			"Unexpected Java element",
1252
			"bar() [in <anonymous #1> [in foo() [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]]]",
1253
			element
1254
		);
1255
	}
1256
	/*
1228
	 * Ensures that the IJavaElement of an IBinding representing a package is correct.
1257
	 * Ensures that the IJavaElement of an IBinding representing a package is correct.
1229
	 */
1258
	 */
1230
	public void testPackage1() throws CoreException {
1259
	public void testPackage1() throws CoreException {

Return to bug 208013