Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at */
 package org.mozilla.javascript.ast;
New expression. Node type is org.mozilla.javascript.Token.NEW.

NewExpression :
      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.
public class NewExpression extends FunctionCall {
    private ObjectLiteral initializer;
         = .;
    public NewExpression() {
    public NewExpression(int pos) {
    public NewExpression(int posint len) {

Returns initializer object, if any.

extra initializer object-literal expression, or null if not specified.
    public ObjectLiteral getInitializer() {
      return ;

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.

initializer extra initializer object. Can be null.
    public void setInitializer(ObjectLiteral initializer) {
      this. = initializer;
      if (initializer != null)
    public String toSource(int depth) {
        StringBuilder sb = new StringBuilder();
        sb.append("new ");
        if ( != null) {
        if ( != null) {
            sb.append(" ");
        return sb.toString();

Visits this node, the target, and each argument. If there is a trailing initializer node, visits that last.
    public void visit(NodeVisitor v) {
        if (v.visit(this)) {
            for (AstNode arg : getArguments()) {
            if ( != null) {
New to GrepCode? Check out our FAQ X