Package com.google.javascript.rhino

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


    if (needResult) {
      Node tempVarNode = NodeUtil.newVarNode(tempName, null)
          .copyInformationFromForTree(expr);
      Node injectionPointParent = injectionPoint.getParent();
      injectionPointParent.addChildBefore(tempVarNode, injectionPoint);
      injectionPointParent.addChildAfter(ifNode, tempVarNode);

      // Replace the expression with the temporary name.
      Node replacementValueNode = IR.name(tempName);
      parent.replaceChild(expr, replacementValueNode);
    } else {
View Full Code Here


        break;
      }
    }

    Node block = exprRoot.getParent();
    block.addChildAfter(stmt, exprRoot);
  }

  private void annotate(Node node) {
    NodeTraversal.traverse(
        compiler, node, new PrepareAst.PrepareAnnotations());
View Full Code Here

      Node block = expr.getParent();

      node.removeChild(functionNode);
      parent.removeChild(node);
      newNameNode.addChildToFront(functionNode);
      block.addChildAfter(newVarNode, expr);

      if (specializationState != null) {
        specializationState.reportRemovedFunction(functionNode, block);
      }
    }
View Full Code Here

      case VAR_DECL_SIMPLE_ASSIGNMENT:
        // Remove the call from the name node.
        parent.removeChild(parent.getFirstChild());
        Preconditions.checkState(parent.getFirstChild() == null);
        // Add the call, after the VAR.
        greatGrandParent.addChildAfter(newBlock, grandParent);
        break;

      case SIMPLE_ASSIGNMENT:
        // The assignment is now part of the inline function so
        // replace it completely.
View Full Code Here

    if (needResult) {
      Node tempVarNode = NodeUtil.newVarNode(tempName, null)
          .copyInformationFromForTree(expr);
      Node injectionPointParent = injectionPoint.getParent();
      injectionPointParent.addChildBefore(tempVarNode, injectionPoint);
      injectionPointParent.addChildAfter(ifNode, tempVarNode);

      // Replace the expression with the temporary name.
      Node replacementValueNode = Node.newString(Token.NAME, tempName);
      parent.replaceChild(expr, replacementValueNode);
    } else {
View Full Code Here

            block = parent;
          }

          // finally node
          if (finallyBlock != null) {
            block.addChildAfter(finallyBlock, tryBlock);
          }
          compiler.reportCodeChange();
          break;

        case Token.RETURN:
View Full Code Here

      groupVar.replaceChild(initializedName, clone);
      // add the assignment now.
      Node initializedVal = initializedName.getFirstChild();
      initializedName.removeChild(initializedVal);
      Node assignmentNode = new Node(Token.ASSIGN, initializedName);
      assignmentNode.addChildAfter(initializedVal, initializedName);
      if (groupVarParent.getType() == Token.FOR) {
        // Handle For and For-In Loops specially. For these, we do not need
        // to construct an EXPR_RESULT node.
        groupVarParent.replaceChild(groupVar, assignmentNode);
      } else {
View Full Code Here

      case VAR_DECL_SIMPLE_ASSIGNMENT:
        // Remove the call from the name node.
        parent.removeChild(parent.getFirstChild());
        Preconditions.checkState(parent.getFirstChild() == null);
        // Add the call, after the VAR.
        greatGrandParent.addChildAfter(newBlock, grandParent);
        break;

      case SIMPLE_ASSIGNMENT:
        // The assignment is now part of the inline function so
        // replace it completely.
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.