internal static bool TreesAreDifferent(Block leftTree, Block rightTree, IEnumerable<TextChange> changes, CancellationToken cancelToken) { // Apply all the pending changes to the original tree // PERF: If this becomes a bottleneck, we can probably do it the other way around, // i.e. visit the tree and find applicable changes for each node. foreach (TextChange change in changes) { cancelToken.ThrowIfCancellationRequested(); var changeOwner = leftTree.LocateOwner(change); // Apply the change to the tree if (changeOwner == null) { return true; } var result = changeOwner.EditHandler.ApplyChange(changeOwner, change, force: true); changeOwner.ReplaceWith(result.EditedSpan); } // Now compare the trees var treesDifferent = !leftTree.EquivalentTo(rightTree); return treesDifferent; }