fix(ConfCache): Load tsv ext doc in back to fix Slow ... EDT
FilenameIndex.getAllFilesByExt(project, "tsv"); Slow operations are prohibited on EDT in 2023.3
This commit is contained in:
@@ -2,6 +2,8 @@ package io.github.linwancen.plugin.show.ext.conf;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -118,21 +120,29 @@ public class ConfCache {
|
||||
}
|
||||
|
||||
public static void loadAll(@NotNull Project project) {
|
||||
DumbService.getInstance(project).smartInvokeLater(() -> {
|
||||
@NotNull Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, TsvLoader.EXT);
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
for (@NotNull VirtualFile file : files) {
|
||||
load(file);
|
||||
sb.append(file.getName()).append("\n");
|
||||
new Task.Backgroundable(project, "Show Load xxx.tree/key/doc/json.tsv") {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
@NotNull Collection<VirtualFile> files = FilenameIndex.getAllFilesByExt(project, TsvLoader.EXT);
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
int i = 0;
|
||||
for (@NotNull VirtualFile file : files) {
|
||||
indicator.setText(file.getName());
|
||||
load(file);
|
||||
indicator.setFraction((double) ++i /files.size());
|
||||
sb.append(file.getName()).append("\n");
|
||||
}
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb);
|
||||
});
|
||||
}
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb);
|
||||
});
|
||||
}.queue();
|
||||
}
|
||||
|
||||
public static void loadFile(@NotNull VirtualFile file, @Nullable Project project) {
|
||||
|
||||
Reference in New Issue
Block a user