Examples of replaceChild()


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

    } else {
      // Only conditionals that are the direct child of an expression statement
      // don't need results, for those simply replace the expression statement.
      Preconditions.checkArgument(parent.isExprResult());
      Node gramps = parent.getParent();
      gramps.replaceChild(parent, ifNode);
    }

    return ifNode;
  }
View Full Code Here

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

      newCall.addChildrenToBack(call.removeChildren());
    }

    // Replace the call.
    Node callParent = call.getParent();
    callParent.replaceChild(call, newCall);

    return newCall;
  }

  private String tempNamePrefix = "JSCompiler_temp";
View Full Code Here

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

      if (result == null) {
        if (removeUnused) {
          parent.removeChild(n);
        } else {
          result = IR.empty().srcref(n);
          parent.replaceChild(n, result);
        }
      } else {
        // A new COMMA expression may not have an existing parent.
        if (result.getParent() != null) {
          result.detachFromParent();
View Full Code Here

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

    Preconditions.checkState(
        NodeUtil.isControlStructureCodeBlock(n, n.getFirstChild()));
    Node block = n.removeFirstChild();

    Node parent =  n.getParent();
    parent.replaceChild(n, block);
    if (mayHaveSideEffects(cond)) {
      Node condStatement = IR.exprResult(cond.detachFromParent())
          .srcref(cond);
      parent.addChildAfter(condStatement, block);
    }
View Full Code Here

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

      functionNode = parent.getLastChild();
      Node expr = parent.getParent();
      Node block = expr.getParent();
      parent.removeChild(functionNode);
      newNameNode.addChildToFront(functionNode);
      block.replaceChild(expr, newVarNode);

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

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

      case SIMPLE_ASSIGNMENT:
        // The assignment is now part of the inline function so
        // replace it completely.
        Preconditions.checkState(grandParent.isExprResult());
        greatGrandParent.replaceChild(grandParent, newBlock);
        break;

      case SIMPLE_CALL:
        // If nothing is looking at the result just replace the call.
        Preconditions.checkState(parent.isExprResult());
View Full Code Here

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

        // If this is a single var declaration, we can at least remove the
        // declaration itself and just leave the value, e.g.,
        // var a = foo(); => foo();
        if (toRemove.getChildCount() == 1) {
          compiler.reportChangeToEnclosingScope(toRemove);
          parent.replaceChild(toRemove,
              IR.exprResult(nameNode.removeFirstChild()));
        }
      } else if (toRemove.isVar() &&
          toRemove.getChildCount() > 1) {
        // For var declarations with multiple names (i.e. var a, b, c),
View Full Code Here

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

      oldNameNode.setString("");

      // Move the function if it's not the child of a label node
      Node parent = n.getParent();
      if (parent.isLabel()) {
        parent.replaceChild(n, var);
      } else {
        parent.removeChild(n);
        parent.addChildToFront(var);
      }
      fnNameNode.addChildToFront(n);
View Full Code Here

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

          replaceWithEmpty(ancestor, ancParent);
          break;
        }
        if (ancestor.isAssign()) {
          Node ancParent = ancestor.getParent();
          ancParent.replaceChild(
              ancestor, ancestor.getLastChild().detachFromParent());
          break;
        }
        if (!NodeUtil.isGet(ancestor)
            && !ancestor.isCall()) {
View Full Code Here

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

        minCond.getMinimized(MinimizationStyle.PREFER_UNNEGATED));
  }

  private Node replaceNode(Node lhs, MinimizedCondition.MeasuredNode rhs) {
    Node parent = lhs.getParent();
    parent.replaceChild(lhs, rhs.getNode());
    if (rhs.isChanged()) {
      reportCodeChange();
    }
    return rhs.getNode();
  }
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.