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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (+51 lines)
Lines 9398-9401 Link Here
9398
		assertNotNull("No java element", javaElement);
9398
		assertNotNull("No java element", javaElement);
9399
		assertEquals("Not a type", IJavaElement.TYPE, javaElement.getElementType());
9399
		assertEquals("Not a type", IJavaElement.TYPE, javaElement.getElementType());
9400
	}
9400
	}
9401
9402
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=201104
9403
	public void test0283() throws JavaModelException {
9404
		String contents =
9405
			"public class X {\n" + 
9406
			"	public @interface Moo {\n" + 
9407
			"		Class<?> value();\n" + 
9408
			"	}\n" + 
9409
			"	@Moo(Bar2.Baz.class)\n" + 
9410
			"	public static class Bar {\n" + 
9411
			"		public static class Baz {\n" + 
9412
			"		}\n" + 
9413
			"	}\n" + 
9414
			"}";
9415
		workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9416
		workingCopy.getBuffer().setContents(contents);
9417
		ASTNode node = runConversion(AST.JLS3, workingCopy, true, true, true);
9418
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9419
		CompilationUnit unit = (CompilationUnit) node;
9420
		assertProblemsSize(unit, 1, "Bar2 cannot be resolved to a type");
9421
		node = getASTNode(unit, 0, 1);
9422
		assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
9423
		TypeDeclaration typeDeclaration = (TypeDeclaration) node;
9424
		final List modifiers = typeDeclaration.modifiers();
9425
		assertEquals("Wrong size", 3, modifiers.size());
9426
		IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
9427
		assertTrue("Not an annotation", extendedModifier instanceof SingleMemberAnnotation);
9428
		SingleMemberAnnotation annotation = (SingleMemberAnnotation) extendedModifier;
9429
		final Expression value = annotation.getValue();
9430
		assertEquals("Not a type literal", ASTNode.TYPE_LITERAL, value.getNodeType());
9431
		TypeLiteral typeLiteral = (TypeLiteral) value;
9432
		final Type type = typeLiteral.getType();
9433
		assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, type.getNodeType());
9434
		SimpleType simpleType = (SimpleType) type;
9435
		final Name name = simpleType.getName();
9436
		assertEquals("Not a qualified name", ASTNode.QUALIFIED_NAME, name.getNodeType());
9437
		QualifiedName qualifiedName = (QualifiedName) name;
9438
		final IBinding binding = qualifiedName.resolveBinding();
9439
		assertNotNull("No binding", binding);
9440
		assertEquals("Wrong value", "Bar2.Baz", qualifiedName.getFullyQualifiedName());
9441
		final Name qualifier = qualifiedName.getQualifier();
9442
		assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, qualifier.getNodeType());
9443
		SimpleName simpleName2 = (SimpleName) qualifier;
9444
		final IBinding binding3 = simpleName2.resolveBinding();
9445
		assertNotNull("No binding3", binding3);
9446
		assertTrue("Not a recovered binding", binding3.isRecovered());
9447
		final IJavaElement javaElement = binding3.getJavaElement();
9448
		assertNotNull("No java element", javaElement);
9449
		assertEquals("Not a compilation unit", IJavaElement.COMPILATION_UNIT, javaElement.getElementType());
9450
		assertNotNull("No parent", javaElement.getParent());
9451
	}
9401
}
9452
}

Return to bug 201104