1
2
3 package net.sourceforge.pmd.ast;
4
5 public class ASTType extends SimpleNode {
6 public ASTType(int id) {
7 super(id);
8 }
9
10 public ASTType(JavaParser p, int id) {
11 super(p, id);
12 }
13
14 /***
15 * Accept the visitor. *
16 */
17 public Object jjtAccept(JavaParserVisitor visitor, Object data) {
18 return visitor.visit(this, data);
19 }
20
21 public int getArrayDepth() {
22 if (jjtGetNumChildren() != 0 && (jjtGetChild(0) instanceof ASTReferenceType || jjtGetChild(0) instanceof ASTPrimitiveType)) {
23 return ((Dimensionable)jjtGetChild(0)).getArrayDepth();
24 }
25 throw new RuntimeException("ASTType.getArrayDepth called, but first child (of " + jjtGetNumChildren() + " total children) is neither a primitive nor a reference type.");
26 }
27
28 public boolean isArray() {
29 return getArrayDepth() > 0;
30 }
31
32
33 }