AbstractEcmascriptNode.java
01 /**
02  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03  */
04 package net.sourceforge.pmd.lang.ecmascript.ast;
05 
06 import net.sourceforge.pmd.lang.ast.AbstractNode;
07 
08 import org.mozilla.javascript.ast.AstNode;
09 
10 public abstract class AbstractEcmascriptNode<T extends AstNode> extends AbstractNode implements EcmascriptNode {
11 
12     protected final T node;
13 
14     public AbstractEcmascriptNode(T node) {
15   super(node.getType());
16   this.node = node;
17   this.beginLine = node.getLineno() 1;
18   this.beginLine = node.getLineno() 1;
19   // TODO Implement positions, or figure out how to do begin/end lines/column
20   //this.beginPosition = node.getAbsolutePosition();
21   //this.endPosition = this.beginPosition + node.getLength();
22     }
23 
24     /**
25      * Accept the visitor. *
26      */
27     public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
28   return visitor.visit(this, data);
29     }
30 
31     /**
32      * Accept the visitor. *
33      */
34     public Object childrenAccept(EcmascriptParserVisitor visitor, Object data) {
35   if (children != null) {
36       for (int i = 0; i < children.length; ++i) {
37     ((EcmascriptNodechildren[i]).jjtAccept(visitor, data);
38       }
39   }
40   return data;
41     }
42 
43     public boolean hasSideEffects() {
44   return node.hasSideEffects();
45     }
46 
47     @Override
48     public int getBeginColumn() {
49   return -1;
50     }
51 
52     @Override
53     public String toString() {
54   return node.shortName();
55     }
56 }