01: /* Generated By:JJTree: Do not edit this line. ASTVariableDeclaratorId.java */
02: package net.sourceforge.pmd.ast;
03:
04: import java.util.List;
05:
06: public class ASTVariableDeclaratorId extends SimpleJavaNode {
07:
08: public ASTVariableDeclaratorId(int id) {
09: super (id);
10: }
11:
12: public ASTVariableDeclaratorId(JavaParser p, int id) {
13: super (p, id);
14: }
15:
16: /**
17: * Accept the visitor. *
18: */
19: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
20: return visitor.visit(this , data);
21: }
22:
23: private int arrayDepth;
24:
25: public void bumpArrayDepth() {
26: arrayDepth++;
27: }
28:
29: public int getArrayDepth() {
30: return arrayDepth;
31: }
32:
33: public boolean isArray() {
34: return arrayDepth > 0;
35: }
36:
37: public boolean isExceptionBlockParameter() {
38: return jjtGetParent().jjtGetParent() instanceof ASTTryStatement;
39: }
40:
41: public SimpleNode getTypeNameNode() {
42: if (jjtGetParent() instanceof ASTFormalParameter) {
43: return findTypeNameNode(jjtGetParent());
44: } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration
45: || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
46: return findTypeNameNode(jjtGetParent().jjtGetParent());
47: }
48: throw new RuntimeException(
49: "Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
50: }
51:
52: public ASTType getTypeNode() {
53: if (jjtGetParent() instanceof ASTFormalParameter) {
54: return (ASTType) jjtGetParent().jjtGetChild(0);
55: } else if (jjtGetParent().jjtGetParent() instanceof ASTLocalVariableDeclaration
56: || jjtGetParent().jjtGetParent() instanceof ASTFieldDeclaration) {
57: SimpleNode n = (SimpleNode) jjtGetParent().jjtGetParent();
58: return (ASTType) n.getFirstChildOfType(ASTType.class);
59: }
60: throw new RuntimeException(
61: "Don't know how to get the type for anything other than ASTLocalVariableDeclaration/ASTFormalParameter/ASTFieldDeclaration");
62: }
63:
64: private SimpleNode findTypeNameNode(Node node) {
65: if (node.jjtGetChild(0) instanceof ASTAnnotation) {
66: ASTType typeNode = (ASTType) node.jjtGetChild(1);
67: return (SimpleNode) typeNode.jjtGetChild(0);
68: }
69: ASTType typeNode = (ASTType) node.jjtGetChild(0);
70: return (SimpleNode) typeNode.jjtGetChild(0);
71: }
72:
73: }
|