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.ast.NewExpression;
    7
    8   public class ASTNewExpression extends AbstractEcmascriptNode<NewExpression> {
    9       public ASTNewExpression(NewExpression newExpression) {
    10  	super(newExpression);
    11      }
    12
    13      /**
    14       * Accept the visitor.
    15       */
    16      public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
    17  	return visitor.visit(this, data);
    18      }
    19
    20      public EcmascriptNode getTarget() {
    21  	return (EcmascriptNode) jjtGetChild(0);
    22      }
    23
    24      public int getNumArguments() {
    25  	return node.getArguments().size();
    26      }
    27
    28      public EcmascriptNode getArgument(int index) {
    29  	return (EcmascriptNode) jjtGetChild(index + 1);
    30      }
    31
    32      public boolean hasArguments() {
    33  	return getNumArguments() != 0;
    34      }
    35
    36      public boolean hasInitializer() {
    37  	return node.getInitializer() != null;
    38      }
    39
    40      public ASTObjectLiteral getInitializer() {
    41  	return (ASTObjectLiteral) jjtGetChild(jjtGetNumChildren() - 1);
    42      }
    43  }