mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
file undo vfs listener integrated into lvcs vfs listener for proper work
This commit is contained in:
@@ -66,8 +66,6 @@ public class IdeaGateway {
|
||||
|
||||
if (!f.isDirectory() && StringUtil.endsWith(f.getNameSequence(), ".class")) return false;
|
||||
|
||||
LocalHistoryImpl.getInstanceImpl().dispatchPendingEvents();
|
||||
|
||||
VersionedFilterData versionedFilterData = getVersionedFilterData();
|
||||
|
||||
boolean isInContent = false;
|
||||
|
||||
+10
-2
@@ -18,6 +18,7 @@ package com.intellij.history.integration;
|
||||
import com.intellij.history.core.LocalHistoryFacade;
|
||||
import com.intellij.history.core.StoredContent;
|
||||
import com.intellij.history.core.tree.Entry;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.command.CommandEvent;
|
||||
import com.intellij.openapi.command.CommandListener;
|
||||
import com.intellij.openapi.util.Key;
|
||||
@@ -26,6 +27,7 @@ import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,10 +40,12 @@ public class LocalHistoryEventDispatcher extends VirtualFileAdapter implements V
|
||||
|
||||
private final LocalHistoryFacade myVcs;
|
||||
private final IdeaGateway myGateway;
|
||||
private final EventDispatcher<VirtualFileListener> myVfsEventsDispatcher = EventDispatcher.create(VirtualFileListener.class);
|
||||
|
||||
public LocalHistoryEventDispatcher(LocalHistoryFacade vcs, IdeaGateway gw) {
|
||||
myVcs = vcs;
|
||||
myGateway = gw;
|
||||
myVfsEventsDispatcher.addListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -204,7 +208,7 @@ public class LocalHistoryEventDispatcher extends VirtualFileAdapter implements V
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
myGateway.runWithVfsEventsDispatchContext(events, true, () -> {
|
||||
for (VFileEvent event : events) {
|
||||
BulkVirtualFileListenerAdapter.fireBefore(this, event);
|
||||
BulkVirtualFileListenerAdapter.fireBefore(myVfsEventsDispatcher.getMulticaster(), event);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -213,8 +217,12 @@ public class LocalHistoryEventDispatcher extends VirtualFileAdapter implements V
|
||||
public void after(@NotNull List<? extends VFileEvent> events) {
|
||||
myGateway.runWithVfsEventsDispatchContext(events, false, () -> {
|
||||
for (VFileEvent event : events) {
|
||||
BulkVirtualFileListenerAdapter.fireAfter(this, event);
|
||||
BulkVirtualFileListenerAdapter.fireAfter(myVfsEventsDispatcher.getMulticaster(), event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addVirtualFileListener(VirtualFileListener virtualFileListener, Disposable disposable) {
|
||||
myVfsEventsDispatcher.addListener(virtualFileListener, disposable);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.intellij.history.integration.ui.models.DirectoryHistoryDialogModel;
|
||||
import com.intellij.history.integration.ui.models.EntireFileHistoryDialogModel;
|
||||
import com.intellij.history.integration.ui.models.HistoryDialogModel;
|
||||
import com.intellij.history.utils.LocalHistoryLog;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -34,6 +35,7 @@ import com.intellij.openapi.util.ShutDownTracker;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileListener;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
@@ -154,10 +156,6 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
ShutDownTracker.getInstance().unregisterShutdownTask(myShutdownTask);
|
||||
}
|
||||
|
||||
protected void dispatchPendingEvents() {
|
||||
myConnection.deliverImmediately();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void cleanupForNextTest() {
|
||||
disposeComponent();
|
||||
@@ -192,6 +190,10 @@ public class LocalHistoryImpl extends LocalHistory implements ApplicationCompone
|
||||
return label(myVcs.putSystemLabel(name, getProjectId(p), color));
|
||||
}
|
||||
|
||||
public void addVFSListenerAfterLocalHistoryOne(VirtualFileListener virtualFileListener, Disposable disposable) {
|
||||
myEventDispatcher.addVirtualFileListener(virtualFileListener, disposable);
|
||||
}
|
||||
|
||||
private Label label(final LabelImpl impl) {
|
||||
return new Label() {
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.util.FileContentUtil;
|
||||
import com.intellij.util.FileContentUtilCore;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -55,11 +55,12 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider
|
||||
myProject = project;
|
||||
if (myProject == null) return;
|
||||
|
||||
myLocalHistory = LocalHistoryImpl.getInstanceImpl().getFacade();
|
||||
myGateway = LocalHistoryImpl.getInstanceImpl().getGateway();
|
||||
LocalHistoryImpl localHistory = LocalHistoryImpl.getInstanceImpl();
|
||||
myLocalHistory = localHistory.getFacade();
|
||||
myGateway = localHistory.getGateway();
|
||||
if (myLocalHistory == null || myGateway == null) return; // local history was not initialized (e.g. in headless environment)
|
||||
|
||||
getFileManager().addVirtualFileListener(this, project);
|
||||
localHistory.addVFSListenerAfterLocalHistoryOne(this, project);
|
||||
myLocalHistory.addListener(new LocalHistoryFacade.Listener() {
|
||||
@Override
|
||||
public void changeAdded(Change c) {
|
||||
@@ -69,10 +70,6 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider
|
||||
}, myProject);
|
||||
}
|
||||
|
||||
private static VirtualFileManager getFileManager() {
|
||||
return VirtualFileManager.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commandStarted(Project p) {
|
||||
if (myProject != p) return;
|
||||
@@ -146,7 +143,7 @@ public class FileUndoProvider extends VirtualFileAdapter implements UndoProvider
|
||||
|
||||
private boolean shouldNotProcess(VirtualFileEvent e) {
|
||||
return isProjectClosed() || !LocalHistory.getInstance().isUnderControl(e.getFile()) || !myIsInsideCommand
|
||||
|| FileContentUtil.FORCE_RELOAD_REQUESTOR.equals(e.getRequestor());
|
||||
|| FileContentUtilCore.FORCE_RELOAD_REQUESTOR.equals(e.getRequestor());
|
||||
}
|
||||
|
||||
private boolean isProjectClosed() {
|
||||
|
||||
Reference in New Issue
Block a user