1 |
| |
2 |
| |
3 |
| package net.sourceforge.pmd.ast; |
4 |
| |
5 |
| public class ASTLocalVariableDeclaration extends AccessNode implements Dimensionable { |
6 |
| |
7 |
0
| public ASTLocalVariableDeclaration(int id) {
|
8 |
0
| super(id);
|
9 |
| } |
10 |
| |
11 |
285
| public ASTLocalVariableDeclaration(JavaParser p, int id) {
|
12 |
285
| super(p, id);
|
13 |
| } |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
748
| public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
19 |
748
| return visitor.visit(this, data);
|
20 |
| } |
21 |
| |
22 |
35
| public boolean isArray() {
|
23 |
35
| return checkType() + checkDecl() > 0;
|
24 |
| } |
25 |
| |
26 |
3
| public int getArrayDepth() {
|
27 |
3
| if (!isArray()) {
|
28 |
0
| return 0;
|
29 |
| } |
30 |
3
| return checkType() + checkDecl();
|
31 |
| } |
32 |
| |
33 |
38
| private int checkType() {
|
34 |
38
| if (jjtGetNumChildren() == 0 || !(jjtGetChild(0) instanceof ASTType)) {
|
35 |
0
| return 0;
|
36 |
| } |
37 |
38
| return ((ASTType) jjtGetChild(0)).getArrayDepth();
|
38 |
| } |
39 |
| |
40 |
38
| private int checkDecl() {
|
41 |
38
| if (jjtGetNumChildren() < 2 || !(jjtGetChild(1) instanceof ASTVariableDeclarator)) {
|
42 |
0
| return 0;
|
43 |
| } |
44 |
38
| return ((ASTVariableDeclaratorId) (jjtGetChild(1).jjtGetChild(0))).getArrayDepth();
|
45 |
| } |
46 |
| |
47 |
0
| public void dump(String prefix) {
|
48 |
0
| String out = "";
|
49 |
0
| if (isArray()) {
|
50 |
0
| out += "(array";
|
51 |
0
| for (int i = 0; i < getArrayDepth(); i++) {
|
52 |
0
| out += "[";
|
53 |
| } |
54 |
0
| out += ")";
|
55 |
| } |
56 |
0
| System.out.println(toString(prefix) + out);
|
57 |
0
| dumpChildren(prefix);
|
58 |
| } |
59 |
| } |