01: package net.sourceforge.pmd.ast;
02:
03: public class SimpleJavaNode extends SimpleNode implements JavaNode {
04:
05: public SimpleJavaNode(JavaParser p, int i) {
06: super (p, i);
07: }
08:
09: public SimpleJavaNode(int i) {
10: super (i);
11: }
12:
13: public void jjtOpen() {
14: if (beginLine == -1 && parser.token.next != null) {
15: beginLine = parser.token.next.beginLine;
16: beginColumn = parser.token.next.beginColumn;
17: }
18: }
19:
20: public void jjtClose() {
21: if (beginLine == -1
22: && (children == null || children.length == 0)) {
23: beginColumn = parser.token.beginColumn;
24: }
25: if (beginLine == -1) {
26: beginLine = parser.token.beginLine;
27: }
28: endLine = parser.token.endLine;
29: endColumn = parser.token.endColumn;
30: }
31:
32: /**
33: * Accept the visitor. *
34: */
35: public Object jjtAccept(JavaParserVisitor visitor, Object data) {
36: return visitor.visit(this , data);
37: }
38:
39: /**
40: * Accept the visitor. *
41: */
42: public Object childrenAccept(JavaParserVisitor visitor, Object data) {
43: if (children != null) {
44: for (int i = 0; i < children.length; ++i) {
45: ((JavaNode) children[i]).jjtAccept(visitor, data);
46: }
47: }
48: return data;
49: }
50:
51: /* You can override these two methods in subclasses of SimpleNode to
52: customize the way the node appears when the tree is dumped. If
53: your output uses more than one line you should override
54: toString(String), otherwise overriding toString() is probably all
55: you need to do.
56:
57: Changing this method is dangerous, since it is used by the XPathRule
58: for evaluating Element Names !!
59: */
60:
61: public String toString() {
62: return JavaParserTreeConstants.jjtNodeName[id];
63: }
64: }
|