Search in sources :

Example 1 with UndoChangeRevertingVisitor

use of com.intellij.history.integration.revertion.UndoChangeRevertingVisitor in project intellij-community by JetBrains.

the class ChangeRange method revert.

public ChangeRange revert(ChangeRange reverse) throws IOException {
    final Ref<Long> first = new Ref<>();
    final Ref<Long> last = new Ref<>();
    LocalHistoryFacade.Listener l = new LocalHistoryFacade.Listener() {

        public void changeAdded(Change c) {
            if (first.isNull())
                first.set(c.getId());
            last.set(c.getId());
        }
    };
    myVcs.addListener(l, null);
    try {
        myVcs.accept(new UndoChangeRevertingVisitor(myGateway, myToChangeId, myFromChangeId));
    } catch (UndoChangeRevertingVisitor.RuntimeIOException e) {
        throw (IOException) e.getCause();
    } finally {
        myVcs.removeListener(l);
    }
    if (reverse != null) {
        if (first.isNull())
            first.set(reverse.myFromChangeId);
        if (last.isNull())
            last.set(reverse.myToChangeId);
    }
    return new ChangeRange(myGateway, myVcs, first.get(), last.get());
}
Also used : Ref(com.intellij.openapi.util.Ref) UndoChangeRevertingVisitor(com.intellij.history.integration.revertion.UndoChangeRevertingVisitor) LocalHistoryFacade(com.intellij.history.core.LocalHistoryFacade) Change(com.intellij.history.core.changes.Change)

Aggregations

LocalHistoryFacade (com.intellij.history.core.LocalHistoryFacade)1 Change (com.intellij.history.core.changes.Change)1 UndoChangeRevertingVisitor (com.intellij.history.integration.revertion.UndoChangeRevertingVisitor)1 Ref (com.intellij.openapi.util.Ref)1