@Override public synchronized void contentChanged(@NotNull NodeState root, @NotNull CommitInfo info) { EditorDiff.process(changeDetector, this.root, root); this.root = root; }
/** * Validates and possibly edits the given subtree by diffing * and recursing through it. * * @param editor editor for the root of the subtree * @param before state of the original subtree * @param after state of the modified subtree * @return exception if the processing failed, {@code null} otherwise */ @Nullable public static CommitFailedException process( @Nullable Editor editor, @NotNull NodeState before, @NotNull NodeState after) { checkNotNull(before); checkNotNull(after); if (editor != null) { try { editor.enter(before, after); EditorDiff diff = new EditorDiff(editor); if (!after.compareAgainstBaseState(before, diff)) { return diff.exception; } editor.leave(before, after); } catch (CommitFailedException e) { return e; } } return null; }
@Override public synchronized void contentChanged(@NotNull NodeState root, @NotNull CommitInfo info) { EditorDiff.process(changeDetector, this.root, root); this.root = root; }
/** * Validates and possibly edits the given subtree by diffing * and recursing through it. * * @param editor editor for the root of the subtree * @param before state of the original subtree * @param after state of the modified subtree * @return exception if the processing failed, {@code null} otherwise */ @CheckForNull public static CommitFailedException process( @CheckForNull Editor editor, @Nonnull NodeState before, @Nonnull NodeState after) { checkNotNull(before); checkNotNull(after); if (editor != null) { try { editor.enter(before, after); EditorDiff diff = new EditorDiff(editor); if (!after.compareAgainstBaseState(before, diff)) { return diff.exception; } editor.leave(before, after); } catch (CommitFailedException e) { return e; } } return null; }
@Override public void run() { EditorDiff.process( new VisibleEditor(TraversingEditor.INSTANCE), before, state); } });
@Override public boolean childNodeChanged( String name, NodeState before, NodeState after) { try { Editor childEditor = editor.childNodeChanged(name, before, after); if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
@Override public void run() { EditorDiff.process( new VisibleEditor(TraversingEditor.INSTANCE), before, state); } });
@Override public boolean childNodeDeleted(String name, NodeState before) { try { NodeState after = MISSING_NODE; Editor childEditor = editor.childNodeDeleted(name, before); if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
private boolean diff(@Nonnull ImmutableTree source, @Nonnull ImmutableTree dest, @Nonnull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); CommitFailedException e = EditorDiff.process(nextValidator , source.getNodeState(), dest.getNodeState()); if (e != null) { throw e; } return true; }
@Override public boolean childNodeChanged( String name, NodeState before, NodeState after) { try { Editor childEditor = editor.childNodeChanged(name, before, after); if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
private boolean diff(@NotNull Tree source, @NotNull Tree dest, @NotNull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); TreeProvider tp = validator.getTreeProvider(); CommitFailedException e = EditorDiff.process(nextValidator , tp.asNodeState(source), tp.asNodeState(dest)); if (e != null) { throw e; } return true; }
@Override public boolean childNodeDeleted(String name, NodeState before) { try { NodeState after = MISSING_NODE; Editor childEditor = editor.childNodeDeleted(name, before); if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
private boolean diff(@NotNull Tree source, @NotNull Tree dest, @NotNull MoveAwarePermissionValidator validator) throws CommitFailedException { Validator nextValidator = validator.visibleValidator(source, dest); TreeProvider tp = validator.getTreeProvider(); CommitFailedException e = EditorDiff.process(nextValidator , tp.asNodeState(source), tp.asNodeState(dest)); if (e != null) { throw e; } return true; }
@Override public boolean childNodeAdded(String name, NodeState after) { try { NodeState before = MISSING_NODE; Editor childEditor = editor.childNodeAdded(name, after); // NOTE: This piece of code is duplicated across this and the // other child node diff methods. The reason for the duplication // is to simplify the frequently occurring long stack traces // in diff processing. if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
@Override @NotNull public NodeState processCommit( @NotNull NodeState before, @NotNull NodeState after, @NotNull CommitInfo info) throws CommitFailedException { checkNotNull(before); checkNotNull(after); checkNotNull(info); NodeBuilder builder = after.builder(); Editor editor = provider.getRootEditor(before, after, builder, info); CommitFailedException exception = EditorDiff.process(editor, before, after); if (exception == null) { return builder.getNodeState(); } else { throw exception; } }
@Override public boolean childNodeAdded(String name, NodeState after) { try { NodeState before = MISSING_NODE; Editor childEditor = editor.childNodeAdded(name, after); // NOTE: This piece of code is duplicated across this and the // other child node diff methods. The reason for the duplication // is to simplify the frequently occurring long stack traces // in diff processing. if (childEditor != null) { childEditor.enter(before, after); EditorDiff diff = new EditorDiff(childEditor); if (!after.compareAgainstBaseState(before, diff)) { exception = diff.exception; return false; } childEditor.leave(before, after); } return true; } catch (CommitFailedException e) { exception = e; return false; } }
@Override @Nonnull public NodeState processCommit( @Nonnull NodeState before, @Nonnull NodeState after, @Nonnull CommitInfo info) throws CommitFailedException { checkNotNull(before); checkNotNull(after); checkNotNull(info); NodeBuilder builder = after.builder(); Editor editor = provider.getRootEditor(before, after, builder, info); CommitFailedException exception = EditorDiff.process(editor, before, after); if (exception == null) { return builder.getNodeState(); } else { throw exception; } }
public static Map<String, Set<String>> compare(NodeState before, NodeState after) { final TestValidator validator = new TestValidator(); EditorDiff.process(validator, before, after); return validator.actual; }
EditorDiff.process(CompositeEditor.compose(editors), this.root, root); this.root = root;
EditorDiff.process(CompositeEditor.compose(editors), this.root, root); this.root = root;