mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MemoryDiskConflictResolver: show the causing trace in tests
This commit is contained in:
+11
@@ -49,6 +49,7 @@ import java.util.Set;
|
||||
class MemoryDiskConflictResolver {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.fileEditor.impl.MemoryDiskConflictResolver");
|
||||
private final Set<VirtualFile> myConflicts = new LinkedHashSet<>();
|
||||
private Throwable myConflictAppeared;
|
||||
|
||||
void beforeContentChange(@NotNull VirtualFileEvent event) {
|
||||
if (event.isFromSave()) return;
|
||||
@@ -66,6 +67,9 @@ class MemoryDiskConflictResolver {
|
||||
LOG.info(" documentStamp:" + documentStamp);
|
||||
LOG.info(" oldFileStamp:" + oldFileStamp);
|
||||
if (myConflicts.isEmpty()) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
myConflictAppeared = new Throwable();
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(this::processConflicts);
|
||||
}
|
||||
myConflicts.add(file);
|
||||
@@ -86,9 +90,16 @@ class MemoryDiskConflictResolver {
|
||||
FileDocumentManager.getInstance().reloadFromDisk(document);
|
||||
}
|
||||
}
|
||||
myConflictAppeared = null;
|
||||
}
|
||||
|
||||
boolean askReloadFromDisk(VirtualFile file, Document document) {
|
||||
if (myConflictAppeared != null) {
|
||||
Throwable trace = myConflictAppeared;
|
||||
myConflictAppeared = null;
|
||||
throw new IllegalStateException("Unexpected memory-disk conflict in tests, please use FileDocumentManager#reloadFromDisk or avoid VFS refresh", trace);
|
||||
}
|
||||
|
||||
String message = UIBundle.message("file.cache.conflict.message.text", file.getPresentableUrl());
|
||||
|
||||
final DialogBuilder builder = new DialogBuilder();
|
||||
|
||||
Reference in New Issue
Block a user