Search in sources :

Example 1 with ASTArrayDimsAndInits

use of net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits in project pmd by pmd.

the class ClassTypeResolver method visit.

@Override
public Object visit(ASTAllocationExpression node, Object data) {
    super.visit(node, data);
    final ASTArrayDimsAndInits dims = node.getFirstChildOfType(ASTArrayDimsAndInits.class);
    if (dims != null) {
        final Class<?> arrayType = ((TypeNode) node.jjtGetChild(0)).getType();
        if (arrayType != null) {
            node.setType(Array.newInstance(arrayType, (int[]) Array.newInstance(int.class, dims.getArrayDepth())).getClass());
        }
    } else {
        rollupTypeUnary(node);
    }
    return data;
}
Also used : ASTArrayDimsAndInits(net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits) TypeNode(net.sourceforge.pmd.lang.java.ast.TypeNode) AbstractJavaTypeNode(net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode)

Aggregations

ASTArrayDimsAndInits (net.sourceforge.pmd.lang.java.ast.ASTArrayDimsAndInits)1 AbstractJavaTypeNode (net.sourceforge.pmd.lang.java.ast.AbstractJavaTypeNode)1 TypeNode (net.sourceforge.pmd.lang.java.ast.TypeNode)1