/** @since 0.8 or earlier */ public static boolean replaceChild(Node parent, Node oldChild, Node newChild) { return replaceChild(parent, oldChild, newChild, false); }
/** @since 0.8 or earlier */ public static boolean replaceChild(Node parent, Node oldChild, Node newChild) { return replaceChild(parent, oldChild, newChild, false); }
final void replaceHelper(Node newNode, CharSequence reason) { CompilerAsserts.neverPartOfCompilation("do not call Node.replaceHelper from compiled code"); assert inAtomicBlock(); if (this.getParent() == null) { throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); } // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() // will always find the root node newNode.parent = this.parent; if (!NodeUtil.replaceChild(this.parent, this, newNode, true)) { this.parent.adoptUnadoptedHelper(newNode); } reportReplace(this, newNode, reason); onReplace(newNode, reason); }
final void replaceHelper(Node newNode, CharSequence reason) { CompilerAsserts.neverPartOfCompilation("do not call Node.replaceHelper from compiled code"); assert inAtomicBlock(); if (this.getParent() == null) { throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); } // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() // will always find the root node newNode.parent = this.parent; if (!NodeUtil.replaceChild(this.parent, this, newNode, true)) { this.parent.adoptUnadoptedHelper(newNode); } reportReplace(this, newNode, reason); onReplace(newNode, reason); }
final void replaceHelper(Node newNode, CharSequence reason) { CompilerAsserts.neverPartOfCompilation(); assert inAtomicBlock(); if (this.getParent() == null) { throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); } if (sourceSection != null && newNode.getSourceSection() == null) { // Pass on the source section to the new node. newNode.assignSourceSection(sourceSection); } // (aw) need to set parent *before* replace, so that (unsynchronized) getRootNode() // will always find the root node newNode.parent = this.parent; if (NodeUtil.replaceChild(this.parent, this, newNode)) { this.parent.adoptHelper(newNode); } else { this.parent.adoptUnadoptedHelper(newNode); } reportReplace(this, newNode, reason); onReplace(newNode, reason); }