Package com.google.javascript.rhino

Examples of com.google.javascript.rhino.Node.addChildToFront()


        nodes = Lists.reverse(nodes);
        replacement = new Node(Token.COMMA);
        Node cur = replacement;
        int i;
        for (i = 0; i < nodes.size() - 2; i++) {
          cur.addChildToFront(nodes.get(i));
          Node t = new Node(Token.COMMA);
          cur.addChildToFront(t);
          cur = t;
        }
        cur.addChildToFront(nodes.get(i));
View Full Code Here


            string length
     */
    Node propValue = IR.string(propName);
    Node propNameNode =
        IR.name(getArrayNotationNameFor(propName));
    propNameNode.addChildToFront(propValue);
    Node var = IR.var(propNameNode);
    root.addChildToFront(var);

    compiler.reportCodeChange();
  }
View Full Code Here

    String globalName = global.name;
    Node globalValue = IR.name(global.name);
    globalValue.putBooleanProp(Node.IS_CONSTANT_NAME, global.isConstant);

    Node globalNameNode = IR.name("GLOBAL_" + globalName);
    globalNameNode.addChildToFront(globalValue);
    Node var = IR.var(globalNameNode);
    root.addChildToFront(var);

    compiler.reportCodeChange();
  }
View Full Code Here

      Node script = getCurrentScriptNode(parent);
      if (reportDependencies) {
        t.getInput().addRequire(moduleName);
      }
      // Rewrite require("name").
      script.addChildToFront(IR.exprResult(
          IR.call(IR.getprop(IR.name("goog"), IR.string("require")),
              IR.string(moduleName))).copyInformationFromForTree(require));
      compiler.reportCodeChange();
    }
View Full Code Here

    NodeTraversal.traverse(compiler, root, this);
    for (Entry<JSModule, List<Node>> entry : functions.entrySet()) {
      JSModule module = entry.getKey();
      Node addingRoot = compiler.getNodeForCodeInsertion(module);
      for (Node n : Lists.reverse(entry.getValue())) {
        addingRoot.addChildToFront(n);
      }
    }
  }

  @Override
View Full Code Here

  @SuppressWarnings("unchecked")
  public void testParse() {
    mode = LanguageMode.ECMASCRIPT5;
    Node a = Node.newString(Token.NAME, "a");
    a.addChildToFront(Node.newString(Token.NAME, "b"));
    List<ParserResult> testCases = ImmutableList.of(
        new ParserResult(
            "3;",
            createScript(new Node(Token.EXPR_RESULT, Node.newNumber(3.0)))),
        new ParserResult(
View Full Code Here

    }
    Node guardName = IR.name(GENERATOR_LOOP_GUARD + generatorCounter.get());
    if (!guard.isEmpty()) {
      Node container = new Node(Token.BLOCK);
      n.replaceChild(guard, container);
      container.addChildToFront(IR.block(IR.exprResult(IR.assign(
        guardName.cloneTree(), guard.cloneTree()))));
      container.addChildToBack(guardName.cloneTree());
    }
    if (!incr.isEmpty()) {
      n.addChildBefore(IR.block(IR.exprResult(incr.detachFromParent())), n.getLastChild());
View Full Code Here

    }
    if (!incr.isEmpty()) {
      n.addChildBefore(IR.block(IR.exprResult(incr.detachFromParent())), n.getLastChild());
    }
    Node block = NodeUtil.getEnclosingType(n, Token.BLOCK);
    block.addChildToFront(IR.var(guardName));
    return true;
  }

  @Override
  public void visit(NodeTraversal t, Node n, Node parent) {
View Full Code Here

   * "var arrayNameUsedInFile = [];"
   */
  private Node newArrayDeclarationNode(NodeTraversal traversal) {
    Node arraylitNode = IR.arraylit();
    Node nameNode = IR.name(createArrayName(traversal));
    nameNode.addChildToFront(arraylitNode);
    Node varNode = IR.var(nameNode);
    return varNode;
  }

  /**
 
View Full Code Here

        node.isWith() ||
        node.isCase() ||
        node.isDefaultCase() ||
        node.isCatch()) {
      Node codeBlock = node.getLastChild();
      codeBlock.addChildToFront(
          newInstrumentationNode(traversal, node.getLineno()));
      return;
    }

    // Add instrumentation code as the first child of a 'try' block.
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.