replaceChild method
DartBlockValueTreeBooleanNode?
replaceChild(
- covariant DartBlockValueTreeBooleanNode oldChild,
- covariant DartBlockValueTreeBooleanNode? newChild
override
Implementation
@override
DartBlockValueTreeBooleanNode? replaceChild(
DartBlockValueTreeBooleanNode oldChild,
DartBlockValueTreeBooleanNode? newChild,
) {
if (newChild != null &&
newChild is! DartBlockValueTreeBooleanGenericNumberNode) {
if (parent == null) {
newChild.parent = null;
return newChild;
} else {
return parent?.replaceChild(this, newChild);
}
}
if (leftChild == oldChild) {
leftChild = newChild as DartBlockValueTreeBooleanGenericNumberNode?;
leftChild?.parent = this;
} else if (rightChild == oldChild) {
rightChild = newChild as DartBlockValueTreeBooleanGenericNumberNode?;
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;
}