1 |
| |
2 |
| |
3 |
| package net.sourceforge.pmd.ast; |
4 |
| |
5 |
| public class ASTVariableDeclaratorId extends SimpleNode { |
6 |
| |
7 |
8
| public ASTVariableDeclaratorId(int id) {
|
8 |
8
| super(id);
|
9 |
| } |
10 |
| |
11 |
890
| public ASTVariableDeclaratorId(JavaParser p, int id) {
|
12 |
890
| super(p, id);
|
13 |
| } |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
2099
| public Object jjtAccept(JavaParserVisitor visitor, Object data) {
|
19 |
2099
| return visitor.visit(this, data);
|
20 |
| } |
21 |
| |
22 |
| private int arrayDepth; |
23 |
| |
24 |
18
| public void bumpArrayDepth() {
|
25 |
18
| arrayDepth++;
|
26 |
| } |
27 |
| |
28 |
43
| public int getArrayDepth() {
|
29 |
43
| return arrayDepth;
|
30 |
| } |
31 |
| |
32 |
0
| public boolean isArray() {
|
33 |
0
| return arrayDepth > 0;
|
34 |
| } |
35 |
| |
36 |
2
| public boolean isExceptionBlockParameter() {
|
37 |
2
| return jjtGetParent().jjtGetParent() instanceof ASTTryStatement;
|
38 |
| } |
39 |
| |
40 |
8
| public SimpleNode getTypeNameNode() {
|
41 |
8
| if (jjtGetParent() instanceof ASTFormalParameter) {
|
42 |
3
| return findTypeNameNode(jjtGetParent());
|
43 |
5
| } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
|
44 |
5
| return findTypeNameNode(jjtGetParent().jjtGetParent());
|
45 |
| } |
46 |
0
| throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
|
47 |
| } |
48 |
| |
49 |
38
| public ASTType getTypeNode() {
|
50 |
38
| if (jjtGetParent() instanceof ASTFormalParameter) {
|
51 |
6
| return (ASTType) jjtGetParent().jjtGetChild(0);
|
52 |
32
| } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
|
53 |
32
| SimpleNode n = (SimpleNode)jjtGetParent().jjtGetParent();
|
54 |
32
| return (ASTType)n.getFirstChildOfType(ASTType.class);
|
55 |
| } |
56 |
0
| throw new RuntimeException("Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
|
57 |
| } |
58 |
| |
59 |
8
| private SimpleNode findTypeNameNode(Node node) {
|
60 |
8
| ASTType typeNode = (ASTType) node.jjtGetChild(0);
|
61 |
8
| return (SimpleNode) typeNode.jjtGetChild(0);
|
62 |
| } |
63 |
| |
64 |
| } |