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       public ASTVariableDeclaratorId(int id) {
7           super(id);
8       }
9   
10      public ASTVariableDeclaratorId(JavaParser p, int id) {
11          super(p, id);
12      }
13  
14      /*** Accept the visitor. **/
15      public Object jjtAccept(JavaParserVisitor visitor, Object data) {
16          return visitor.visit(this, data);
17      }
18  
19      public boolean isExceptionBlockParameter() {
20          return jjtGetParent().jjtGetParent() instanceof ASTTryStatement;
21      }
22  
23      public SimpleNode getTypeNameNode() {
24          if (jjtGetParent() instanceof ASTFormalParameter) {
25              return findTypeNameNode(jjtGetParent());
26          } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
27              return findTypeNameNode(jjtGetParent().jjtGetParent());
28          }
29          throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
30      }
31  
32      public ASTType getTypeNode() {
33          if (jjtGetParent() instanceof ASTFormalParameter) {
34              return (ASTType)jjtGetParent().jjtGetChild(0);
35          } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
36              return (ASTType)(jjtGetParent().jjtGetParent().jjtGetChild(0));
37          }
38          throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
39      }
40  
41      public void dump(String prefix) {
42          System.out.println(toString(prefix) + ":" + getImage());
43          dumpChildren(prefix);
44      }
45  
46      private SimpleNode findTypeNameNode(Node node) {
47          ASTType typeNode = (ASTType) node.jjtGetChild(0);
48          return (SimpleNode) typeNode.jjtGetChild(0);
49      }
50  }