### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java,v retrieving revision 1.252 diff -u -r1.252 ASTConverter15Test.java --- src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 24 Aug 2007 16:42:18 -0000 1.252 +++ src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java 24 Aug 2007 16:44:13 -0000 @@ -9398,4 +9398,55 @@ assertNotNull("No java element", javaElement); assertEquals("Not a type", IJavaElement.TYPE, javaElement.getElementType()); } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=201104 + public void test0283() throws JavaModelException { + String contents = + "public class X {\n" + + " public @interface Moo {\n" + + " Class value();\n" + + " }\n" + + " @Moo(Bar2.Baz.class)\n" + + " public static class Bar {\n" + + " public static class Baz {\n" + + " }\n" + + " }\n" + + "}"; + workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/); + workingCopy.getBuffer().setContents(contents); + ASTNode node = runConversion(AST.JLS3, workingCopy, true, true, true); + assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType()); + CompilationUnit unit = (CompilationUnit) node; + assertProblemsSize(unit, 1, "Bar2 cannot be resolved to a type"); + node = getASTNode(unit, 0, 1); + assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType()); + TypeDeclaration typeDeclaration = (TypeDeclaration) node; + final List modifiers = typeDeclaration.modifiers(); + assertEquals("Wrong size", 3, modifiers.size()); + IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0); + assertTrue("Not an annotation", extendedModifier instanceof SingleMemberAnnotation); + SingleMemberAnnotation annotation = (SingleMemberAnnotation) extendedModifier; + final Expression value = annotation.getValue(); + assertEquals("Not a type literal", ASTNode.TYPE_LITERAL, value.getNodeType()); + TypeLiteral typeLiteral = (TypeLiteral) value; + final Type type = typeLiteral.getType(); + assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, type.getNodeType()); + SimpleType simpleType = (SimpleType) type; + final Name name = simpleType.getName(); + assertEquals("Not a qualified name", ASTNode.QUALIFIED_NAME, name.getNodeType()); + QualifiedName qualifiedName = (QualifiedName) name; + final IBinding binding = qualifiedName.resolveBinding(); + assertNotNull("No binding", binding); + assertEquals("Wrong value", "Bar2.Baz", qualifiedName.getFullyQualifiedName()); + final Name qualifier = qualifiedName.getQualifier(); + assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, qualifier.getNodeType()); + SimpleName simpleName2 = (SimpleName) qualifier; + final IBinding binding3 = simpleName2.resolveBinding(); + assertNotNull("No binding3", binding3); + assertTrue("Not a recovered binding", binding3.isRecovered()); + final IJavaElement javaElement = binding3.getJavaElement(); + assertNotNull("No java element", javaElement); + assertEquals("Not a compilation unit", IJavaElement.COMPILATION_UNIT, javaElement.getElementType()); + assertNotNull("No parent", javaElement.getParent()); + } }