Class NewExpression

All Implemented Interfaces:
Comparable<AstNode>, Iterable<Node>

public class NewExpression extends FunctionCall
New expression. Node type is Token.NEW.
NewExpression :
      MemberExpression
      new NewExpression
This node is a subtype of FunctionCall, mostly for internal code sharing. Structurally a NewExpression node is very similar to a FunctionCall, so it made a certain amount of sense.
  • Constructor Details

    • NewExpression

      public NewExpression()
    • NewExpression

      public NewExpression(int pos)
    • NewExpression

      public NewExpression(int pos, int len)
  • Method Details

    • getInitializer

      public ObjectLiteral getInitializer()
      Returns initializer object, if any.
      Returns:
      extra initializer object-literal expression, or null if not specified.
    • setInitializer

      public void setInitializer(ObjectLiteral initializer)
      Sets initializer object. Rhino supports an experimental syntax of the form new expr [ ( arglist ) ] [initializer], in which initializer is an object literal that is used to set additional properties on the newly-created expr object.
      Parameters:
      initializer - extra initializer object. Can be null.
    • toSource

      public String toSource(int depth)
      Description copied from class: AstNode
      Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

      Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

      Overrides:
      toSource in class FunctionCall
      Parameters:
      depth - the current recursion depth, typically beginning at 0 when called on the root node.
    • visit

      public void visit(NodeVisitor v)
      Visits this node, the target, and each argument. If there is a trailing initializer node, visits that last.
      Overrides:
      visit in class FunctionCall
      Parameters:
      v - the object to call with this node and its children