View Javadoc

1   /* Generated By:JJTree: Do not edit this line. ASTVariableDeclaratorId.java */
2   
3   package net.sourceforge.pmd.ast;
4   
5   public class ASTVariableDeclaratorId extends SimpleNode {
6   
7       public ASTVariableDeclaratorId(int id) {
8           super(id);
9       }
10  
11      public ASTVariableDeclaratorId(JavaParser p, int id) {
12          super(p, id);
13      }
14  
15      /***
16       * Accept the visitor. *
17       */
18      public Object jjtAccept(JavaParserVisitor visitor, Object data) {
19          return visitor.visit(this, data);
20      }
21  
22      private int arrayDepth;
23  
24      public void bumpArrayDepth() {
25          arrayDepth++;
26      }
27  
28      public int getArrayDepth() {
29          return arrayDepth;
30      }
31  
32      public boolean isArray() {
33          return arrayDepth > 0;
34      }
35  
36      public boolean isExceptionBlockParameter() {
37          return jjtGetParent().jjtGetParent() instanceof ASTTryStatement;
38      }
39  
40      public SimpleNode getTypeNameNode() {
41          if (jjtGetParent() instanceof ASTFormalParameter) {
42              return findTypeNameNode(jjtGetParent());
43          } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
44              return findTypeNameNode(jjtGetParent().jjtGetParent());
45          }
46          throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
47      }
48  
49      public ASTType getTypeNode() {
50          if (jjtGetParent() instanceof ASTFormalParameter) {
51              return (ASTType) jjtGetParent().jjtGetChild(0);
52          } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
53              return (ASTType) (jjtGetParent().jjtGetParent().jjtGetChild(0));
54          }
55          throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
56      }
57  
58      private SimpleNode findTypeNameNode(Node node) {
59          ASTType typeNode = (ASTType) node.jjtGetChild(0);
60          return (SimpleNode) typeNode.jjtGetChild(0);
61      }
62  
63      public void dump(String prefix) {
64          System.out.println(toString(prefix) + "(" + getImage() + ")");
65          dumpChildren(prefix);
66      }
67  
68  }