All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.pmd.lang.java.ast.ASTArrayAllocation Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
/**
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.lang.java.ast;

import org.checkerframework.checker.nullness.qual.Nullable;

/**
 * An array creation expression. The dimensions of the array type may
 * be initialized with a length expression (in which case they're
 * {@link ASTArrayDimExpr ArrayDimExpr} nodes).
 *
 * 
 *
 * ArrayCreationExpression ::= "new" {@link ASTArrayType ArrayType} {@link ASTArrayInitializer ArrayInitializer}?
 *
 * 
*/ public final class ASTArrayAllocation extends AbstractJavaExpr implements ASTPrimaryExpression { ASTArrayAllocation(int id) { super(id); } @Override protected R acceptVisitor(JavaVisitor visitor, P data) { return visitor.visit(this, data); } /** * Returns the node representing the array type being instantiated. */ public ASTArrayType getTypeNode() { return (ASTArrayType) getChild(0); } /** Returns the initializer, if present. */ @Nullable public ASTArrayInitializer getArrayInitializer() { return AstImplUtil.getChildAs(this, getNumChildren() - 1, ASTArrayInitializer.class); } /** * Returns the number of dimensions of the created array. */ public int getArrayDepth() { return getTypeNode().getArrayDepth(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy