Package org.mozilla.javascript.ast

Examples of org.mozilla.javascript.ast.Block


    return binary(BinaryOperator.COMMA, nodes);
  }

  @Override
  public AstNode block(Iterable<AstNode> statements) {
    Block block = new Block();
    for (AstNode stmt : statements) {
      if (stmt != null) {
        block.addStatement(stmt);
      }
    }
    return block;
  }
View Full Code Here


    CatchClause c = new CatchClause();
    c.setVarName(cast(varName, Name.class));
    if (body instanceof Block) {
      c.setBody((Block) body);
    } else {
      Block b = new Block();
      b.addStatement(body);
      c.setBody(b);
    }
    return c;
  }
View Full Code Here

    if (name != null) {
      func.setFunctionName((Name) name(name));
    }
    func.setParams(list(params));
    if (body == null) {
      func.setBody(new Block());
    } else if (body instanceof Block) {
      func.setBody(body);
    } else {
      func.setBody(addStatement(null, body));
    }
View Full Code Here

  public AstNode addStatement(AstNode blockOrStatement, AstNode statement) {
    if (blockOrStatement instanceof Block) {
      ((Block) blockOrStatement).addStatement(statement);
      return blockOrStatement;
    }
    Block block = new Block();
    if (blockOrStatement != null) {
      block.addStatement(blockOrStatement);
    }
    if (statement != null) {
      block.addStatement(statement);
    }
    return block;
  }
View Full Code Here

        blockOrStatement.addChildrenToFront(statement);
        statement.setParent(blockOrStatement);
      }
      return blockOrStatement;
    }
    Block block = new Block();
    if (statement != null) {
      block.addStatement(statement);
    }
    if (blockOrStatement != null) {
      block.addStatement(blockOrStatement);
    }
    return block;
  }
View Full Code Here

   * @param node
   *            The child.
   * @return The new block.
   */
  private Block createBlockWithNode(AstNode node) {
    Block b = new Block();
    b.addChild(node);
    return b;
  }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ast.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.