mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
file property pushers: re-queue on task cancellation, start dumb mode after large synchronous push
This commit is contained in:
+38
-7
@@ -20,12 +20,14 @@
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.ProjectTopics;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionException;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressWrapper;
|
||||
@@ -92,6 +94,7 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
|
||||
}
|
||||
|
||||
public void processAfterVfsChanges(@NotNull List<? extends VFileEvent> events) {
|
||||
boolean pushedSomething = false;
|
||||
List<Runnable> delayedTasks = ContainerUtil.newArrayList();
|
||||
for (VFileEvent event : events) {
|
||||
final VirtualFile file = event.getFile();
|
||||
@@ -105,6 +108,7 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
|
||||
// push synchronously to avoid entering dumb mode in the middle of a meaningful write action
|
||||
// avoid dumb mode for just one file
|
||||
doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
|
||||
pushedSomething = true;
|
||||
}
|
||||
else if (!ProjectCoreUtil.isProjectOrWorkspaceFile(file)) {
|
||||
ContainerUtil.addIfNotNull(delayedTasks, createRecursivePushTask(file, pushers));
|
||||
@@ -115,11 +119,26 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
|
||||
}
|
||||
// push synchronously to avoid entering dumb mode in the middle of a meaningful write action
|
||||
doPushRecursively(file, pushers, ProjectRootManager.getInstance(myProject).getFileIndex());
|
||||
pushedSomething = true;
|
||||
}
|
||||
}
|
||||
if (!delayedTasks.isEmpty()) {
|
||||
queueTasks(delayedTasks);
|
||||
}
|
||||
if (pushedSomething) {
|
||||
Application application = ApplicationManager.getApplication();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
scheduleDumbModeReindexingIfNeeded();
|
||||
}
|
||||
};
|
||||
if (application.isUnitTestMode()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
application.invokeLater(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,15 +213,27 @@ public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater
|
||||
if (task == null) {
|
||||
break;
|
||||
}
|
||||
hadTasks = true;
|
||||
task.run();
|
||||
try {
|
||||
task.run();
|
||||
hadTasks = true;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
queueTasks(Collections.singletonList(task)); // reschedule dumb mode and ensure the canceled task is enqueued again
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
if (hadTasks && !myProject.isDisposed()) {
|
||||
DumbModeTask task = FileBasedIndexProjectHandler.createChangedFilesIndexingTask(myProject);
|
||||
if (task != null) {
|
||||
DumbService.getInstance(myProject).queueTask(task);
|
||||
}
|
||||
if (hadTasks) {
|
||||
scheduleDumbModeReindexingIfNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleDumbModeReindexingIfNeeded() {
|
||||
if (myProject.isDisposed()) return;
|
||||
|
||||
DumbModeTask task = FileBasedIndexProjectHandler.createChangedFilesIndexingTask(myProject);
|
||||
if (task != null) {
|
||||
DumbService.getInstance(myProject).queueTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user