View Javadoc

1   /* Generated By:JJTree: Do not edit this line. ASTFormalParameter.java */
2   
3   package net.sourceforge.pmd.ast;
4   
5   public class ASTFormalParameter extends AccessNode implements Dimensionable {
6       public ASTFormalParameter(int id) {
7           super(id);
8       }
9   
10      public ASTFormalParameter(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 boolean isArray() {
22          return checkType() + checkDecl() > 0;
23      }
24  
25      public int getArrayDepth() {
26          if (!isArray()) {
27              return 0;
28          }
29          return checkType() + checkDecl();
30      }
31  
32      private int checkType() {
33          if (jjtGetNumChildren() == 0 || !(jjtGetChild(0) instanceof ASTType)) {
34              return 0;
35          }
36          return ((ASTType) jjtGetChild(0)).getArrayDepth();
37      }
38  
39      private int checkDecl() {
40          if (jjtGetNumChildren() < 2 || !(jjtGetChild(1) instanceof ASTVariableDeclarator)) {
41              return 0;
42          }
43          return ((ASTVariableDeclaratorId) (jjtGetChild(1).jjtGetChild(0))).getArrayDepth();
44      }
45  
46      public void dump(String prefix) {
47          System.out.println(collectDumpedModifiers(prefix));
48          dumpChildren(prefix);
49      }
50  
51  }