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.UnaryExpression;
9   
10  public class ASTUnaryExpression extends AbstractEcmascriptNode<UnaryExpression> {
11      public ASTUnaryExpression(UnaryExpression unaryExpression) {
12  	super(unaryExpression);
13  	if (unaryExpression.getOperator() == Token.VOID) {
14  	    super.setImage("void");
15  	} else {
16  	    super.setImage(AstRoot.operatorToString(unaryExpression.getOperator()));
17  	}
18      }
19  
20      /**
21       * Accept the visitor.
22       */
23      @Override
24      public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
25  	return visitor.visit(this, data);
26      }
27      
28      public EcmascriptNode getOperand() {
29  	return (EcmascriptNode)jjtGetChild(0);
30      }
31  
32      public boolean isPrefix() {
33  	return node.isPrefix();
34      }
35  
36      public boolean isPostfix() {
37  	return node.isPostfix();
38      }
39  }