Package com.google.javascript.rhino

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


        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

    String result = stringAsString.substring(start, start + length);
    Node resultNode = IR.string(result);

    Node parent = n.getParent();
    parent.replaceChild(n, resultNode);
    reportCodeChange();
    return resultNode;
  }

  /**
 
View Full Code Here

    String result = stringAsString.substring(start, end);
    Node resultNode = IR.string(result);

    Node parent = n.getParent();
    parent.replaceChild(n, resultNode);
    reportCodeChange();
    return resultNode;
  }

  /**
 
View Full Code Here

    }

    Node resultNode = IR.string(
        stringAsString.substring(index, index + 1));
    Node parent = n.getParent();
    parent.replaceChild(n, resultNode);
    reportCodeChange();
    return resultNode;
  }

  /**
 
View Full Code Here

      return n;
    }

    Node resultNode = IR.number(stringAsString.charAt(index));
    Node parent = n.getParent();
    parent.replaceChild(n, resultNode);
    reportCodeChange();
    return resultNode;
  }

  /**
 
View Full Code Here

      arrayOfStrings.addChildToBack(
          IR.string(stringArray[i]).srcref(stringNode));
    }

    Node parent = n.getParent();
    parent.replaceChild(n, arrayOfStrings);
    reportCodeChange();
    return arrayOfStrings;
  }
}
View Full Code Here

    Node parent = var.getParent();

    // Special case when we are in FOR-IN loop.
    if (NodeUtil.isForIn(parent)) {
      var.removeChild(name);
      parent.replaceChild(var, name);
    } else if (var.hasOneChild()) {
      // The removal is easy when there is only one variable in the VAR node.
      if (name.hasChildren()) {
        Node value = name.removeFirstChild();
        var.removeChild(name);
View Full Code Here

    Preconditions.checkState(
        ref.node.getParent().isExprResult());
    Node parent = ref.node.getParent();
    Node gramps = parent.getParent();
    gramps.replaceChild(parent, varNode);
    compiler.reportCodeChange();
  }


  /**
 
View Full Code Here

      if (result == null) {
        if (removeUnused) {
          parent.removeChild(n);
        } else {
          result = new Node(Token.EMPTY).copyInformationFrom(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

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.