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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-1 / +55 lines)
Lines 46-52 Link Here
46
	}
46
	}
47
47
48
	static {
48
	static {
49
//		TESTS_NUMBERS = new int[] { 281 };
49
//		TESTS_NUMBERS = new int[] { 282 };
50
//		TESTS_RANGE = new int[] { 277, -1 };
50
//		TESTS_RANGE = new int[] { 277, -1 };
51
//		TESTS_NAMES = new String[] {"test0204"};
51
//		TESTS_NAMES = new String[] {"test0204"};
52
	}
52
	}
Lines 9344-9347 Link Here
9344
		IAnnotationBinding[] annotations = typeBinding.getAnnotations();
9344
		IAnnotationBinding[] annotations = typeBinding.getAnnotations();
9345
		assertEquals("wrong size", 1, annotations.length);
9345
		assertEquals("wrong size", 1, annotations.length);
9346
	}
9346
	}
9347
9348
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=190622
9349
	public void test0282() throws JavaModelException {
9350
		String contents =
9351
			"public class X {\n" + 
9352
			"	public @interface Moo {\n" + 
9353
			"		Class<?> value();\n" + 
9354
			"	}\n" + 
9355
			"	@Moo(Bar.Baz.class)\n" + 
9356
			"	public static class Bar {\n" + 
9357
			"		public static class Baz {\n" + 
9358
			"		}\n" + 
9359
			"	}\n" + 
9360
			"}";
9361
		workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
9362
		workingCopy.getBuffer().setContents(contents);
9363
		ASTNode node = runConversion(AST.JLS3, workingCopy, true, true, true);
9364
		assertEquals("Not a compilation unit", ASTNode.COMPILATION_UNIT, node.getNodeType());
9365
		CompilationUnit unit = (CompilationUnit) node;
9366
		assertProblemsSize(unit, 0);
9367
		node = getASTNode(unit, 0, 1);
9368
		assertEquals("Not a type declaration", ASTNode.TYPE_DECLARATION, node.getNodeType());
9369
		TypeDeclaration typeDeclaration = (TypeDeclaration) node;
9370
		final List modifiers = typeDeclaration.modifiers();
9371
		assertEquals("Wrong size", 3, modifiers.size());
9372
		IExtendedModifier extendedModifier = (IExtendedModifier) modifiers.get(0);
9373
		assertTrue("Not an annotation", extendedModifier instanceof SingleMemberAnnotation);
9374
		SingleMemberAnnotation annotation = (SingleMemberAnnotation) extendedModifier;
9375
		final Expression value = annotation.getValue();
9376
		assertEquals("Not a type literal", ASTNode.TYPE_LITERAL, value.getNodeType());
9377
		TypeLiteral typeLiteral = (TypeLiteral) value;
9378
		final Type type = typeLiteral.getType();
9379
		assertEquals("Not a simple type", ASTNode.SIMPLE_TYPE, type.getNodeType());
9380
		SimpleType simpleType = (SimpleType) type;
9381
		final Name name = simpleType.getName();
9382
		assertEquals("Not a qualified name", ASTNode.QUALIFIED_NAME, name.getNodeType());
9383
		QualifiedName qualifiedName = (QualifiedName) name;
9384
		final IBinding binding = qualifiedName.resolveBinding();
9385
		assertNotNull("No binding", binding);
9386
		assertEquals("Wrong value", "Bar.Baz", qualifiedName.getFullyQualifiedName());
9387
		final SimpleName simpleName = qualifiedName.getName();
9388
		final IBinding binding2 = simpleName.resolveBinding();
9389
		assertNotNull("No binding2", binding2);
9390
		assertFalse("Not a recovered binding", binding2.isRecovered());
9391
		final Name qualifier = qualifiedName.getQualifier();
9392
		assertEquals("Not a simple name", ASTNode.SIMPLE_NAME, qualifier.getNodeType());
9393
		SimpleName simpleName2 = (SimpleName) qualifier;
9394
		final IBinding binding3 = simpleName2.resolveBinding();
9395
		assertNotNull("No binding3", binding3);
9396
		assertFalse("Not a recovered binding", binding3.isRecovered());
9397
		final IJavaElement javaElement = binding3.getJavaElement();
9398
		assertNotNull("No java element", javaElement);
9399
		assertEquals("Not a type", IJavaElement.TYPE, javaElement.getElementType());
9400
	}
9347
}
9401
}

Return to bug 190622