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 |
| |
9 |
| private boolean isVarargs; |
10 |
| |
11 |
| |
12 |
2
| public void setVarargs() {
|
13 |
2
| isVarargs = true;
|
14 |
| } |
15 |
| |
16 |
2
| public boolean isVarargs() {
|
17 |
2
| return isVarargs;
|
18 |
| } |
19 |
| |
20 |
1
| public ASTFormalParameter(int id) {
|
21 |
1
| super(id);
|
22 |
| } |
23 |
| |
24 |
490
| public ASTFormalParameter(JavaParser p, int id) {
|
25 |
490
| super(p, id);
|
26 |
| } |
27 |
| |
28 |
1339
| public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
29 |
1339
| return visitor.visit(this, data);
|
30 |
| } |
31 |
| |
32 |
33
| public boolean hasSuppressWarningsAnnotationFor(Rule rule) {
|
33 |
33
| for (int i = 0; i < jjtGetNumChildren(); i++) {
|
34 |
65
| if (jjtGetChild(i) instanceof ASTAnnotation) {
|
35 |
1
| ASTAnnotation a = (ASTAnnotation) jjtGetChild(i);
|
36 |
1
| if (a.suppresses(rule)) {
|
37 |
1
| return true;
|
38 |
| } |
39 |
| } |
40 |
| } |
41 |
32
| return false;
|
42 |
| } |
43 |
| |
44 |
25
| public boolean isArray() {
|
45 |
25
| return checkType() + checkDecl() > 0;
|
46 |
| } |
47 |
| |
48 |
0
| public int getArrayDepth() {
|
49 |
0
| if (!isArray()) {
|
50 |
0
| return 0;
|
51 |
| } |
52 |
0
| return checkType() + checkDecl();
|
53 |
| } |
54 |
| |
55 |
50
| public ASTType getTypeNode() {
|
56 |
50
| for (int i = 0; i < jjtGetNumChildren(); i++) {
|
57 |
50
| if (jjtGetChild(i) instanceof ASTType) {
|
58 |
50
| return (ASTType) jjtGetChild(i);
|
59 |
| } |
60 |
| } |
61 |
0
| throw new IllegalStateException("ASTType not found");
|
62 |
| } |
63 |
| |
64 |
25
| private int checkType() {
|
65 |
25
| return getTypeNode().getArrayDepth();
|
66 |
| } |
67 |
| |
68 |
25
| private ASTVariableDeclaratorId getDecl() {
|
69 |
25
| return (ASTVariableDeclaratorId) jjtGetChild(jjtGetNumChildren()-1);
|
70 |
| } |
71 |
| |
72 |
25
| private int checkDecl() {
|
73 |
25
| return getDecl().getArrayDepth();
|
74 |
| } |
75 |
| |
76 |
0
| public void dump(String prefix) {
|
77 |
0
| System.out.println(collectDumpedModifiers(prefix));
|
78 |
0
| dumpChildren(prefix);
|
79 |
| } |
80 |
| |
81 |
| } |