1 |
| |
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 |
1
| public ASTFormalParameter(int id) {
|
9 |
1
| super(id);
|
10 |
| } |
11 |
| |
12 |
399
| public ASTFormalParameter(JavaParser p, int id) {
|
13 |
399
| super(p, id);
|
14 |
| } |
15 |
| |
16 |
977
| public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
17 |
977
| return visitor.visit(this, data);
|
18 |
| } |
19 |
| |
20 |
27
| public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
|
21 |
27
| for (int i = 0; i < jjtGetNumChildren(); i++) {
|
22 |
53
| if (jjtGetChild(i) instanceof ASTAnnotation) {
|
23 |
1
| ASTAnnotation a = (ASTAnnotation) jjtGetChild(i);
|
24 |
1
| if (a.suppresses(rule)) {
|
25 |
1
| return true;
|
26 |
| } |
27 |
| } |
28 |
| } |
29 |
26
| return false;
|
30 |
| } |
31 |
| |
32 |
18
| public boolean isArray() {
|
33 |
18
| return checkType() + checkDecl() > 0;
|
34 |
| } |
35 |
| |
36 |
0
| public int getArrayDepth() {
|
37 |
0
| if (!isArray()) {
|
38 |
0
| return 0;
|
39 |
| } |
40 |
0
| return checkType() + checkDecl();
|
41 |
| } |
42 |
| |
43 |
18
| private int checkType() {
|
44 |
18
| if (jjtGetNumChildren() == 0 || !(jjtGetChild(0) instanceof ASTType)) {
|
45 |
0
| return 0;
|
46 |
| } |
47 |
18
| return ((ASTType) jjtGetChild(0)).getArrayDepth();
|
48 |
| } |
49 |
| |
50 |
18
| private int checkDecl() {
|
51 |
18
| if (jjtGetNumChildren() < 2 || !(jjtGetChild(1) instanceof ASTVariableDeclarator)) {
|
52 |
18
| return 0;
|
53 |
| } |
54 |
0
| return ((ASTVariableDeclaratorId) (jjtGetChild(1).jjtGetChild(0))).getArrayDepth();
|
55 |
| } |
56 |
| |
57 |
0
| public void dump(String prefix) {
|
58 |
0
| System.out.println(collectDumpedModifiers(prefix));
|
59 |
0
| dumpChildren(prefix);
|
60 |
| } |
61 |
| |
62 |
| } |