View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   /* Generated By:JJTree: Do not edit this line. ASTType.java */
5   
6   package net.sourceforge.pmd.lang.java.ast;
7   
8   public class ASTType extends AbstractJavaTypeNode {
9       public ASTType(int id) {
10          super(id);
11      }
12  
13      public ASTType(JavaParser p, int id) {
14          super(p, id);
15      }
16  
17      /**
18       * Accept the visitor. *
19       */
20      @Override
21      public Object jjtAccept(JavaParserVisitor visitor, Object data) {
22          return visitor.visit(this, data);
23      }
24  
25      public String getTypeImage() {
26          ASTPrimitiveType prim = getFirstDescendantOfType(ASTPrimitiveType.class);
27          if (prim != null) {
28              return prim.getImage();
29          }
30          return getFirstDescendantOfType(ASTClassOrInterfaceType.class).getImage();
31      }
32  
33      public int getArrayDepth() {
34          if (jjtGetNumChildren() != 0 && (jjtGetChild(0) instanceof ASTReferenceType || jjtGetChild(0) instanceof ASTPrimitiveType)) {
35              return ((Dimensionable) jjtGetChild(0)).getArrayDepth();
36          }
37          throw new RuntimeException("ASTType.getArrayDepth called, but first child (of " + jjtGetNumChildren() + " total children) is neither a primitive nor a reference type.");
38      }
39  
40      public boolean isArray() {
41          return getArrayDepth() > 0;
42      }
43  
44  
45  }