use of net.sourceforge.pmd.lang.java.ast.ASTAllocationExpression in project pmd by pmd.
the class ClassTypeResolverTest method testNestedAnonymousClass.
@Test
public void testNestedAnonymousClass() throws Exception {
Node acu = parseAndTypeResolveForClass(NestedAnonymousClass.class, "1.8");
ASTAllocationExpression allocationExpression = acu.getFirstDescendantOfType(ASTAllocationExpression.class);
ASTAllocationExpression nestedAllocation = // get the declaration (boundary)
allocationExpression.getFirstDescendantOfType(ASTClassOrInterfaceBodyDeclaration.class).getFirstDescendantOfType(// and dive for the nested allocation
ASTAllocationExpression.class);
TypeNode child = (TypeNode) nestedAllocation.jjtGetChild(0);
Assert.assertTrue(Converter.class.isAssignableFrom(child.getType()));
Assert.assertSame(String.class, child.getTypeDefinition().getGenericType(0).getType());
}
Aggregations