fix: TreeUI should be accessed only from EDT fixed #89
This commit is contained in:
@@ -29,7 +29,7 @@ public class ReloadExtDocAction extends CopyReferenceAction {
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
FileLoader.EPN.getExtensionList().forEach(fileLoader -> fileLoader.loadAll(project));
|
||||
FileLoader.loadAll(project);
|
||||
} catch (Throwable t) {
|
||||
LOG.info("ReloadExtDocAction catch Throwable but log to record.", t);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package io.github.linwancen.plugin.show.ext.action;
|
||||
import com.intellij.ide.actions.CopyReferenceAction;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.concurrency.EdtExecutorService;
|
||||
import io.github.linwancen.plugin.show.ext.listener.FileLoader;
|
||||
import io.github.linwancen.plugin.show.settings.ShowBundle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -33,8 +33,7 @@ public class ResetExtDocAction extends CopyReferenceAction {
|
||||
if (project == null) {
|
||||
return;
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() ->
|
||||
ProjectView.getInstance(project).refresh());
|
||||
EdtExecutorService.getInstance().execute(() -> ProjectView.getInstance(project).refresh());
|
||||
} catch (Throwable t) {
|
||||
LOG.info("ConfFileChangeListener catch Throwable but log to record.", t);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.github.linwancen.plugin.show.ext.conf;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
@@ -149,9 +148,6 @@ public class ConfCache extends FileLoader {
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("Ext doc conf load all complete {} files\n{}", files.size(), sb);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FileLoadInitListener implements DumbService.DumbModeListener, Proje
|
||||
@NotNull Project[] projects = ProjectManager.getInstance().getOpenProjects();
|
||||
for (@NotNull Project project : projects) {
|
||||
PROJECT_LOAD_MAP.computeIfAbsent(project, k -> {
|
||||
FileLoader.EPN.getExtensionList().forEach(fileLoader -> fileLoader.loadAll(project));
|
||||
FileLoader.loadAll(project);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
import com.intellij.util.concurrency.EdtExecutorService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -67,10 +68,14 @@ public abstract class FileLoader {
|
||||
*/
|
||||
protected abstract void loadFileImpl(@NotNull VirtualFile file, @Nullable Project project);
|
||||
|
||||
public void loadAll(@NotNull Project project) {
|
||||
public static void loadAll(@NotNull Project project) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() ->
|
||||
DumbService.getInstance(project).runReadActionInSmartMode(()
|
||||
-> loadAllImpl(project)));
|
||||
DumbService.getInstance(project).runReadActionInSmartMode(() -> {
|
||||
if (!project.isDisposed()) {
|
||||
FileLoader.EPN.getExtensionList().forEach(fileLoader -> fileLoader.loadAllImpl(project));
|
||||
EdtExecutorService.getInstance().execute(() -> ProjectView.getInstance(project).refresh());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
public void visitChildrenRecursively(@NotNull Project project, @NotNull VirtualFile dir, @NotNull StringBuilder sb) {
|
||||
@@ -94,7 +99,7 @@ public abstract class FileLoader {
|
||||
ApplicationManager.getApplication().runReadAction(() -> {
|
||||
loadFileImpl(file, project);
|
||||
if (project != null && !project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
EdtExecutorService.getInstance().execute(() -> ProjectView.getInstance(project).refresh());
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -36,9 +35,6 @@ public class OllamaModelsCache extends FileLoader {
|
||||
}
|
||||
@NotNull StringBuilder sb = new StringBuilder();
|
||||
visitChildrenRecursively(project, dir, sb);
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("ollama manifests load all complete files\n{}", sb);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.github.linwancen.plugin.show.ext.sql;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.FilenameIndex;
|
||||
@@ -66,9 +65,6 @@ public class SqlCache extends FileLoader {
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("SQL doc load all complete {} files\n{}", files.size(), sb);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.github.linwancen.plugin.show.lang.vue;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
import com.intellij.lang.ecmascript6.psi.ES6ImportCall;
|
||||
import com.intellij.lang.ecmascript6.psi.ES6ImportedBinding;
|
||||
import com.intellij.lang.javascript.psi.JSArrayLiteralExpression;
|
||||
@@ -62,9 +61,6 @@ public class VueRouterCache extends FileLoader {
|
||||
if (files.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (!project.isDisposed()) {
|
||||
ProjectView.getInstance(project).refresh();
|
||||
}
|
||||
LOG.info("Vue Router load all complete {} files\n{}", files.size(), sb);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user