View Javadoc

1   /* Generated By:JJTree: Do not edit this line. ASTFormalParameter.java */
2   
3   package net.sourceforge.pmd.ast;
4   
5   import net.sourceforge.pmd.Rule;
6   
7   public class ASTFormalParameter extends AccessNode implements Dimensionable, CanSuppressWarnings {
8       public ASTFormalParameter(int id) {
9           super(id);
10      }
11  
12      public ASTFormalParameter(JavaParser p, int id) {
13          super(p, id);
14      }
15  
16      public Object jjtAccept(JavaParserVisitor visitor, Object data) {
17          return visitor.visit(this, data);
18      }
19  
20      public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
21          for (int i = 0; i < jjtGetNumChildren(); i++) {
22              if (jjtGetChild(i) instanceof ASTAnnotation) {
23                  ASTAnnotation a = (ASTAnnotation) jjtGetChild(i);
24                  if (a.suppresses(rule)) {
25                      return true;
26                  }
27              }
28          }
29          return false;
30      }
31  
32      public boolean isArray() {
33          return checkType() + checkDecl() > 0;
34      }
35  
36      public int getArrayDepth() {
37          if (!isArray()) {
38              return 0;
39          }
40          return checkType() + checkDecl();
41      }
42  
43      private int checkType() {
44          if (jjtGetNumChildren() == 0 || !(jjtGetChild(0) instanceof ASTType)) {
45              return 0;
46          }
47          return ((ASTType) jjtGetChild(0)).getArrayDepth();
48      }
49  
50      private int checkDecl() {
51          if (jjtGetNumChildren() < 2 || !(jjtGetChild(1) instanceof ASTVariableDeclarator)) {
52              return 0;
53          }
54          return ((ASTVariableDeclaratorId) (jjtGetChild(1).jjtGetChild(0))).getArrayDepth();
55      }
56  
57      public void dump(String prefix) {
58          System.out.println(collectDumpedModifiers(prefix));
59          dumpChildren(prefix);
60      }
61  
62  }