1
2
3
4
5
6
7 package net.sourceforge.pmd.lang.plsql.ast;
8
9 import net.sourceforge.pmd.lang.symboltable.Scope;
10
11 public abstract class AbstractPLSQLNode extends net.sourceforge.pmd.lang.ast.AbstractNode implements PLSQLNode {
12 protected Object value;
13 protected PLSQLParser parser;
14 protected Scope scope;
15
16 public AbstractPLSQLNode(int i) {
17 super(i);
18 }
19
20 public AbstractPLSQLNode(PLSQLParser p, int i) {
21 this(i);
22 parser = p;
23 }
24
25 public void jjtOpen() {
26 if (beginLine == -1 && parser.token.next != null) {
27 beginLine = parser.token.next.beginLine;
28 beginColumn = parser.token.next.beginColumn;
29 }
30 }
31
32 public void jjtClose() {
33 if (beginLine == -1 && (children == null || children.length == 0)) {
34 beginColumn = parser.token.beginColumn;
35 }
36 if (beginLine == -1) {
37 beginLine = parser.token.beginLine;
38 }
39 endLine = parser.token.endLine;
40 endColumn = parser.token.endColumn;
41 }
42
43 public void jjtSetValue(Object value) { this.value = value; }
44 public Object jjtGetValue() { return value; }
45
46 @Override
47 public Object jjtAccept(PLSQLParserVisitor visitor, Object data) {
48 return visitor.visit(this, data);
49 }
50
51 @Override
52 public Object childrenAccept(PLSQLParserVisitor visitor, Object data) {
53 if (children != null) {
54 for (int i = 0; i < children.length; ++i) {
55 ((PLSQLNode)children[i]).jjtAccept(visitor, data);
56 }
57 }
58 return data;
59 }
60
61
62
63
64
65
66
67 public String toString() { return PLSQLParserTreeConstants.jjtNodeName[id]; }
68 public String toString(String prefix) { return prefix + toString(); }
69
70
71
72
73 public void dump(String prefix) {
74 System.out.println(toString(prefix));
75 if (children != null) {
76 for (int i = 0; i < children.length; ++i) {
77 AbstractPLSQLNode n = (AbstractPLSQLNode)children[i];
78 if (n != null) {
79 n.dump(prefix + " ");
80 }
81 }
82 }
83 }
84
85
86
87
88
89
90
91
92 public String getCanonicalImage() { return PLSQLParser.canonicalName(this.getImage()); }
93
94
95
96
97
98
99
100
101
102 static public String getCanonicalImage(String image) { return PLSQLParser.canonicalName(image); }
103
104 @Override
105 public Scope getScope() {
106 if (scope == null) {
107 return ((PLSQLNode) parent).getScope();
108 }
109 return scope;
110 }
111
112 @Override
113 public void setScope(Scope scope) {
114 this.scope = scope;
115 }
116 }
117
118