replaceChild method
DartBlockValueTreeBooleanNode?
replaceChild(
- covariant DartBlockValueTreeBooleanNode oldChild,
- covariant DartBlockValueTreeBooleanNode? newChild
override
Implementation
@override
DartBlockValueTreeBooleanNode? replaceChild(
DartBlockValueTreeBooleanNode oldChild,
DartBlockValueTreeBooleanNode? newChild,
) {
if (leftChild == oldChild) {
leftChild = newChild;
leftChild?.parent = this;
} else if (rightChild == oldChild) {
rightChild = newChild;
rightChild?.parent = this;
}
if (leftChild == null) {
operator = null;
if (parent == null) {
rightChild?.parent = null;
return rightChild;
} else {
return parent?.replaceChild(this, rightChild);
}
}
if (rightChild == null && operator == null) {
if (parent == null) {
leftChild?.parent = null;
return leftChild;
} else {
return parent?.replaceChild(this, leftChild);
}
}
return this;
}