View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.ecmascript.ast;
5   
6   import org.mozilla.javascript.Token;
7   import org.mozilla.javascript.ast.AstRoot;
8   import org.mozilla.javascript.ast.InfixExpression;
9   
10  public class AbstractInfixEcmascriptNode<T extends InfixExpression> extends AbstractEcmascriptNode<T> {
11  
12      public AbstractInfixEcmascriptNode(T infixExpression) {
13  	this(infixExpression, true);
14      }
15  
16      public AbstractInfixEcmascriptNode(T infixExpression, boolean setImage) {
17  	super(infixExpression);
18  	if (setImage) {
19  	    if (infixExpression.getOperator() == Token.ASSIGN_BITXOR) {
20  	        super.setImage("^=");
21  	    } else {
22  	        super.setImage(AstRoot.operatorToString(infixExpression.getOperator()));
23  	    }
24  	}
25      }
26  
27      public EcmascriptNode getLeft() {
28  	return (EcmascriptNode) jjtGetChild(0);
29      }
30  
31      public EcmascriptNode getRight() {
32  	return (EcmascriptNode) jjtGetChild(1);
33      }
34  }