addWrite method
This write with node written at path.
Implementation
CompoundWrite addWrite(Path path, Node node) {
if (path.isEmpty) {
return CompoundWrite(ImmutableTree<Node>(node));
}
final PathAndValue<Node>? rootMost = writeTree.findRootMostValueAndPath(
path,
);
if (rootMost != null) {
final Path relativePath = Path.relative(rootMost.path, path);
Node value = rootMost.value;
final ChildKey? back = relativePath.back;
if (back != null &&
back.isPriorityKey &&
value.getChild(relativePath.parent!).isEmpty) {
// Ignore priority updates on empty nodes.
return this;
}
value = value.updateChild(relativePath, node);
return CompoundWrite(writeTree.set(rootMost.path, value));
}
return CompoundWrite(writeTree.setTree(path, ImmutableTree<Node>(node)));
}