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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTModelBridgeTests.java (+42 lines)
Lines 310-315 Link Here
310
	}
310
	}
311
311
312
	/*
312
	/*
313
	 * Ensures that the IJavaElement of an IBinding representing an annotation on an annotation type is correct.
314
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249844 )
315
	 */
316
	public void testAnnotation6() throws JavaModelException {
317
		ASTNode node = buildAST(
318
			"/*start*/@MyAnnot/*end*/\n" + 
319
			"public @interface X {\n" +
320
			"}\n" +
321
			"@interface MyAnnot {\n" +
322
			"}"
323
		);
324
		IBinding binding = ((Annotation) node).resolveAnnotationBinding();
325
		IJavaElement element = binding.getJavaElement();
326
		assertElementEquals(
327
			"Unexpected Java element",
328
			"@MyAnnot [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]",
329
			element
330
		);
331
	}
332
	
333
	/*
334
	 * Ensures that the IJavaElement of an IBinding representing an annotation on an enum type is correct.
335
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=249844 )
336
	 */
337
	public void testAnnotation7() throws JavaModelException {
338
		ASTNode node = buildAST(
339
			"/*start*/@MyAnnot/*end*/\n" + 
340
			"public enum X {\n" +
341
			"}\n" +
342
			"@interface MyAnnot {\n" +
343
			"}"
344
		);
345
		IBinding binding = ((Annotation) node).resolveAnnotationBinding();
346
		IJavaElement element = binding.getJavaElement();
347
		assertElementEquals(
348
			"Unexpected Java element",
349
			"@MyAnnot [in X [in [Working copy] X.java [in <default> [in src [in P]]]]]",
350
			element
351
		);
352
	}
353
354
	/*
313
	 * Ensures that the IJavaElement of an IBinding representing an anonymous type is correct.
355
	 * Ensures that the IJavaElement of an IBinding representing an anonymous type is correct.
314
	 */
356
	 */
315
	public void testAnonymousType() throws JavaModelException {
357
	public void testAnonymousType() throws JavaModelException {
(-)dom/org/eclipse/jdt/core/dom/AnnotationBinding.java (-1 / +3 lines)
Lines 112-119 Link Here
112
				parentElement =  ((ICompilationUnit) cu).getPackageDeclaration(pkgName);
112
				parentElement =  ((ICompilationUnit) cu).getPackageDeclaration(pkgName);
113
			}
113
			}
114
			break;
114
			break;
115
		case ASTNode.ENUM_DECLARATION:
115
		case ASTNode.TYPE_DECLARATION:
116
		case ASTNode.TYPE_DECLARATION:
116
			parentElement = ((TypeDeclaration) parent).resolveBinding().getJavaElement();
117
		case ASTNode.ANNOTATION_TYPE_DECLARATION:
118
			parentElement = ((AbstractTypeDeclaration) parent).resolveBinding().getJavaElement();
117
			break;
119
			break;
118
		case ASTNode.FIELD_DECLARATION:
120
		case ASTNode.FIELD_DECLARATION:
119
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) ((FieldDeclaration) parent).fragments().get(0);
121
			VariableDeclarationFragment fragment = (VariableDeclarationFragment) ((FieldDeclaration) parent).fragments().get(0);

Return to bug 249844