diff --git a/README.md b/README.md
index 6269320..91342bd 100644
--- a/README.md
+++ b/README.md
@@ -112,6 +112,7 @@ Show doc comment at the Project view Tree, line End, json, other
English Change Notes:
+- 2.13 ★ Cache for 2023.3
- 2.12 Add project-view-tree support Markdown and Asciidoc
- 2.11 Add project-view-tree description from pom.xml and build.gradle
- 2.10 Add line-end-comment not doc comment
@@ -153,6 +154,7 @@ Show doc comment at the Project view Tree, line End, json, other
中文更新说明:
+- 2.13 ★ 缓存用于支持 2023.3
- 2.12 增加 文件树注释 支持 Markdown and Asciidoc
- 2.11 增加 文件树注释 模块描述 来自 pom.xml 和 build.gradle
- 2.10 增加 行末注释 非文档注释
diff --git a/build.gradle b/build.gradle
index d7dda61..dabe009 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,7 +4,7 @@ plugins {
}
group 'io.github.linwancen'
-version '2.12.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
+version '2.13.0.' + (new Date().format('yyyy.MM.dd_HH.mm'))
repositories {
mavenCentral()
@@ -87,6 +87,7 @@ patchPluginXml {
changeNotes = """
English Change Notes:
+- 2.13 ★ Cache for 2023.3
- 2.12 Add project-view-tree support Markdown and Asciidoc
- 2.11 Add project-view-tree description from pom.xml and build.gradle
- 2.10 Add line-end-comment not doc comment
@@ -128,6 +129,7 @@ patchPluginXml {
中文更新说明:
+- 2.13 ★ 缓存用于支持 2023.3
- 2.12 增加 文件树注释 支持 Markdown and Asciidoc
- 2.11 增加 文件树注释 模块描述 来自 pom.xml 和 build.gradle
- 2.10 增加 行末注释 非文档注释
diff --git a/src/main/java/io/github/linwancen/plugin/show/LineEnd.java b/src/main/java/io/github/linwancen/plugin/show/LineEnd.java
index d6c1cd8..776dcd8 100644
--- a/src/main/java/io/github/linwancen/plugin/show/LineEnd.java
+++ b/src/main/java/io/github/linwancen/plugin/show/LineEnd.java
@@ -2,15 +2,19 @@ package io.github.linwancen.plugin.show;
import com.intellij.json.JsonFileType;
import com.intellij.json.json5.Json5FileType;
-import com.intellij.openapi.editor.*;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorLinePainter;
+import com.intellij.openapi.editor.LineExtensionInfo;
+import com.intellij.openapi.editor.SelectionModel;
+import com.intellij.openapi.editor.VisualPosition;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import io.github.linwancen.plugin.show.bean.FileInfo;
import io.github.linwancen.plugin.show.bean.LineInfo;
+import io.github.linwancen.plugin.show.cache.LineEndCacheUtils;
import io.github.linwancen.plugin.show.ext.LineExt;
import io.github.linwancen.plugin.show.lang.base.BaseLangDoc;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
@@ -22,7 +26,6 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.function.Consumer;
public class LineEnd extends EditorLinePainter {
@@ -41,8 +44,8 @@ public class LineEnd extends EditorLinePainter {
}
@Nullable
- private static List getLineExtensionInfos(@NotNull Project project,
- @NotNull VirtualFile file, int lineNumber) {
+ private static Collection getLineExtensionInfos(@NotNull Project project,
+ @NotNull VirtualFile file, int lineNumber) {
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
if (!settings.showLineEndComment) {
return null;
@@ -63,23 +66,32 @@ public class LineEnd extends EditorLinePainter {
}
}
}
- if (DumbService.isDumb(project)) {
- return null;
- }
- if (!file.exists()) {
- return null;
- }
@Nullable LineInfo info = LineInfo.of(file, project, lineNumber);
+ if (info == null) {
+ return null;
+ }
+ if (settings.lineEndCache) {
+ return LineEndCacheUtils.get(info);
+ } else {
+ @Nullable LineExtensionInfo lineExt = lineExt(info);
+ if (lineExt == null) {
+ return null;
+ }
+ return Collections.singleton(lineExt);
+ }
+ }
+
+ @Nullable
+ public static LineExtensionInfo lineExt(@NotNull LineInfo info) {
@Nullable String doc = lineDocSkipHave(info);
if (doc == null) {
return null;
}
- @NotNull TextAttributes textAttr = file.getFileType().equals(JsonFileType.INSTANCE)
- || file.getFileType().equals(Json5FileType.INSTANCE)
- ? settings.lineEndJsonTextAttr
- : settings.lineEndTextAttr;
- @NotNull LineExtensionInfo lineExt = new LineExtensionInfo(settings.lineEndPrefix + doc, textAttr);
- return Collections.singletonList(lineExt);
+ @NotNull TextAttributes textAttr = info.file.getFileType().equals(JsonFileType.INSTANCE)
+ || info.file.getFileType().equals(Json5FileType.INSTANCE)
+ ? info.appSettings.lineEndJsonTextAttr
+ : info.appSettings.lineEndTextAttr;
+ return new LineExtensionInfo(info.appSettings.lineEndPrefix + doc, textAttr);
}
public static void textWithDoc(@NotNull FileInfo fileInfo, int startLine, int endLine,
@@ -110,8 +122,11 @@ public class LineEnd extends EditorLinePainter {
func.accept(sb.toString());
}
- private static @Nullable String lineDocSkipHave(@Nullable LineInfo info) {
- @Nullable String doc = lineDoc(info);
+ private static @Nullable String lineDocSkipHave(@NotNull LineInfo info) {
+ @Nullable String doc = LineExt.doc(info);
+ if (doc == null) {
+ doc = BaseLangDoc.langDoc(info);
+ }
if (doc == null) {
return null;
}
@@ -121,16 +136,4 @@ public class LineEnd extends EditorLinePainter {
}
return trimDoc;
}
-
- private static @Nullable String lineDoc(@Nullable LineInfo info) {
- if (info == null) {
- return null;
- }
- // override some text
- @Nullable String doc = LineExt.doc(info);
- if (doc != null) {
- return doc;
- }
- return BaseLangDoc.langDoc(info);
- }
}
diff --git a/src/main/java/io/github/linwancen/plugin/show/LineEndAdd.java b/src/main/java/io/github/linwancen/plugin/show/LineEndAdd.java
index a2036c2..5537cd9 100644
--- a/src/main/java/io/github/linwancen/plugin/show/LineEndAdd.java
+++ b/src/main/java/io/github/linwancen/plugin/show/LineEndAdd.java
@@ -76,6 +76,7 @@ public class LineEndAdd extends DumbAwareAction {
new Task.Backgroundable(project, "Show LineEndAdd " + list.size() + " " + list.get(0)) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
+ indicator.setIndeterminate(false);
WriteCommandAction.runWriteCommandAction(project, () -> {
for (int i = 0; i < list.size(); i++) {
VirtualFile file = list.get(i);
diff --git a/src/main/java/io/github/linwancen/plugin/show/LineEndCopy.java b/src/main/java/io/github/linwancen/plugin/show/LineEndCopy.java
index e97d459..6ff649a 100644
--- a/src/main/java/io/github/linwancen/plugin/show/LineEndCopy.java
+++ b/src/main/java/io/github/linwancen/plugin/show/LineEndCopy.java
@@ -52,6 +52,7 @@ public class LineEndCopy extends DumbAwareAction {
new Task.Backgroundable(project, "Show LineEndCopy " + info.file.getName()) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
+ indicator.setIndeterminate(false);
ApplicationManager.getApplication().runReadAction(() -> {
int startLine = 0;
int endLine = info.document.getLineCount() - 1;
diff --git a/src/main/java/io/github/linwancen/plugin/show/Tree.java b/src/main/java/io/github/linwancen/plugin/show/Tree.java
index 0cd9033..d49139e 100644
--- a/src/main/java/io/github/linwancen/plugin/show/Tree.java
+++ b/src/main/java/io/github/linwancen/plugin/show/Tree.java
@@ -5,6 +5,7 @@ import com.intellij.ide.projectView.ProjectViewNode;
import com.intellij.ide.projectView.ProjectViewNodeDecorator;
import com.intellij.ide.util.treeView.PresentableNodeDescriptor.ColoredFragment;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.Project;
import com.intellij.packageDependencies.ui.PackageDependenciesNode;
@@ -13,6 +14,7 @@ import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
import io.github.linwancen.plugin.show.bean.FuncEnum;
import io.github.linwancen.plugin.show.bean.SettingsInfo;
+import io.github.linwancen.plugin.show.cache.TreeCacheUtils;
import io.github.linwancen.plugin.show.ext.TreeExt;
import io.github.linwancen.plugin.show.lang.base.BaseLangDoc;
import io.github.linwancen.plugin.show.settings.AppSettingsState;
@@ -33,20 +35,30 @@ public class Tree implements ProjectViewNodeDecorator {
public void decorate(@NotNull ProjectViewNode node, @NotNull PresentationData data) {
try {
decorateImpl(node, data);
+ } catch (ProcessCanceledException ignore) {
+ // ignore
} catch (Throwable e) {
LOG.info("Tree catch Throwable but log to record.", e);
}
}
private void decorateImpl(@NotNull ProjectViewNode> node, @NotNull PresentationData data) {
- if (!AppSettingsState.getInstance().showTreeComment) {
+ @NotNull AppSettingsState state = AppSettingsState.getInstance();
+ if (!state.showTreeComment) {
return;
}
@Nullable Project project = node.getProject();
if (project == null) {
return;
}
- if (DumbService.isDumb(project)) {
+ @Nullable String extDoc = TreeExt.doc(node);
+ if (extDoc != null) {
+ addText(data, extDoc);
+ return;
+ }
+ if (state.treeCache) {
+ @Nullable String doc = TreeCacheUtils.treeDoc(node, project);
+ addText(data, doc);
return;
}
DumbService.getInstance(project).runReadActionInSmartMode(() ->
@@ -68,11 +80,7 @@ public class Tree implements ProjectViewNodeDecorator {
}
@Nullable
- private String treeDoc(@NotNull ProjectViewNode> node, @NotNull Project project) {
- @Nullable String doc = TreeExt.doc(node);
- if (doc != null) {
- return doc;
- }
+ public static String treeDoc(@NotNull ProjectViewNode> node, @NotNull Project project) {
@NotNull SettingsInfo info = SettingsInfo.of(project, FuncEnum.TREE);
@Nullable String relFileDoc = RelFileDoc.relFileDoc(node, info);
if (relFileDoc != null) {
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateEditorListener.java b/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateEditorListener.java
new file mode 100644
index 0000000..e5841ba
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateEditorListener.java
@@ -0,0 +1,59 @@
+package io.github.linwancen.plugin.show.cache;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.fileEditor.FileEditorManager;
+import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
+import com.intellij.openapi.fileEditor.FileEditorManagerListener;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+/**
+ * call ConfCache.loadFile
+ */
+public class CacheUpdateEditorListener implements FileEditorManagerListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CacheUpdateEditorListener.class);
+
+ @Override
+ public void selectionChanged(@NotNull FileEditorManagerEvent event) {
+ @NotNull Project project = event.getManager().getProject();
+ @Nullable VirtualFile file = event.getNewFile();
+ if (file == null) {
+ return;
+ }
+ ApplicationManager.getApplication().executeOnPooledThread(() -> {
+ if (project.isDisposed()) {
+ LineEndCacheUtils.cache.remove(project);
+ return;
+ }
+ @Nullable Map> fileMap = LineEndCacheUtils.cache.get(project);
+ if (fileMap == null) {
+ return;
+ }
+ @Nullable Map lineMap = fileMap.get(file);
+ if (lineMap == null) {
+ return;
+ }
+ lineMap.forEach((integer, lineEndCache) -> lineEndCache.selectChanged = true);
+ });
+ }
+
+ @Override
+ public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
+ @NotNull Project project = source.getProject();
+ ApplicationManager.getApplication().executeOnPooledThread(() -> {
+ if (project.isDisposed()) {
+ LineEndCacheUtils.cache.remove(project);
+ return;
+ }
+ Map> fileMap = LineEndCacheUtils.cache.get(project);
+ fileMap.remove(file);
+ });
+ }
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateProjectListener.java b/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateProjectListener.java
new file mode 100644
index 0000000..b83d794
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/CacheUpdateProjectListener.java
@@ -0,0 +1,22 @@
+package io.github.linwancen.plugin.show.cache;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.project.ProjectManagerListener;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CacheUpdateProjectListener implements ProjectManagerListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CacheUpdateProjectListener.class);
+
+ @Override
+ public void projectClosed(@NotNull Project project) {
+ try {
+ LineEndCacheUtils.cache.remove(project);
+ TreeCacheUtils.cache.remove(project);
+ } catch (Throwable e) {
+ LOG.info("CacheUpdateProjectListener catch Throwable but log to record.", e);
+ }
+ }
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCache.java b/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCache.java
new file mode 100644
index 0000000..29a3107
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCache.java
@@ -0,0 +1,27 @@
+package io.github.linwancen.plugin.show.cache;
+
+import com.intellij.openapi.editor.LineExtensionInfo;
+import io.github.linwancen.plugin.show.bean.LineInfo;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+public class LineEndCache {
+ @NotNull public String code;
+ @NotNull public List lineExtList;
+ public boolean selectChanged = false;
+ /** null if updated */
+ @Nullable public volatile LineInfo info;
+
+ public LineEndCache(@NotNull String code, @NotNull List right, @NotNull LineInfo info) {
+ this.code = code;
+ this.lineExtList = right;
+ this.info = info;
+ }
+
+ public void updated() {
+ selectChanged = false;
+ info = null;
+ }
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCacheUtils.java b/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCacheUtils.java
new file mode 100644
index 0000000..599e976
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/LineEndCacheUtils.java
@@ -0,0 +1,97 @@
+package io.github.linwancen.plugin.show.cache;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.LineExtensionInfo;
+import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.util.concurrency.AppExecutorUtil;
+import io.github.linwancen.plugin.show.LineEnd;
+import io.github.linwancen.plugin.show.bean.LineInfo;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+public class LineEndCacheUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(LineEndCacheUtils.class);
+
+ public static final Map>> cache = new ConcurrentHashMap<>();
+
+ public static @Nullable Collection get(@NotNull LineInfo info) {
+ try {
+ @NotNull LineEndCache lineCache = cache
+ .computeIfAbsent(info.project, a -> new ConcurrentHashMap<>())
+ .computeIfAbsent(info.file, a -> new ConcurrentHashMap<>())
+ .computeIfAbsent(info.lineNumber, a -> new LineEndCache(info.text, new ArrayList<>(1), info));
+ if (lineCache.selectChanged || !info.text.equals(lineCache.code)) {
+ lineCache.lineExtList.clear();
+ lineCache.info = info;
+ }
+ checkScheduleAndInit();
+ return lineCache.lineExtList;
+ } catch (Throwable e) {
+ LOG.info("LineEndCache catch Throwable but log to record.", e);
+ return null;
+ }
+ }
+
+ private static volatile boolean isRun = false;
+
+ private static void checkScheduleAndInit() {
+ if (!isRun) {
+ synchronized (LineEndCacheUtils.class) {
+ if (!isRun) {
+ isRun = true;
+ AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay(() -> {
+ try {
+ ApplicationManager.getApplication().runReadAction(LineEndCacheUtils::cacheUpdate);
+ } catch (Exception e) {
+ LOG.info("LineEndCache checkScheduleAndInit catch Throwable but log to record.", e);
+ }
+ }, 0L, 1L, TimeUnit.SECONDS);
+ }
+ }
+ }
+ }
+
+ private static void cacheUpdate() {
+ cache.forEach((project, fileMap) -> {
+ try {
+ if (project.isDisposed()) {
+ cache.remove(project);
+ return;
+ }
+ if (DumbService.isDumb(project)) {
+ return;
+ }
+ fileMap.forEach((file, lineMap) ->
+ lineMap.forEach((lineNumber, lineEndCache) -> {
+ try {
+ @Nullable LineInfo info = lineEndCache.info;
+ if (info == null) {
+ return;
+ }
+ @Nullable LineExtensionInfo lineExt = LineEnd.lineExt(info);
+ lineEndCache.updated();
+ lineEndCache.code = info.text;
+ if (lineExt == null) {
+ return;
+ }
+ lineEndCache.lineExtList.add(lineExt);
+ } catch (Exception e) {
+ LOG.info("LineEndCache lineMap.forEach catch Throwable but log to record.", e);
+ }
+ }));
+ } catch (Exception e) {
+ LOG.info("LineEndCache cache.forEach catch Throwable but log to record.", e);
+ }
+ });
+ }
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/TreeCache.java b/src/main/java/io/github/linwancen/plugin/show/cache/TreeCache.java
new file mode 100644
index 0000000..a4be54b
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/TreeCache.java
@@ -0,0 +1,9 @@
+package io.github.linwancen.plugin.show.cache;
+
+import org.jetbrains.annotations.Nullable;
+
+public class TreeCache {
+ @Nullable
+ public String doc;
+ public volatile boolean needUpdate = true;
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/cache/TreeCacheUtils.java b/src/main/java/io/github/linwancen/plugin/show/cache/TreeCacheUtils.java
new file mode 100644
index 0000000..5399199
--- /dev/null
+++ b/src/main/java/io/github/linwancen/plugin/show/cache/TreeCacheUtils.java
@@ -0,0 +1,85 @@
+package io.github.linwancen.plugin.show.cache;
+
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.intellij.ide.projectView.ProjectViewNode;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.DumbService;
+import com.intellij.openapi.project.Project;
+import com.intellij.util.concurrency.AppExecutorUtil;
+import io.github.linwancen.plugin.show.Tree;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+public class TreeCacheUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(TreeCacheUtils.class);
+
+ public static final Map, TreeCache>> cache = new ConcurrentHashMap<>();
+
+ @Nullable
+ public static String treeDoc(@NotNull ProjectViewNode> node, @NotNull Project project) {
+ try {
+ @NotNull TreeCache treeCache = cache
+ .computeIfAbsent(project, a -> new ConcurrentHashMap<>())
+ .computeIfAbsent(node, a -> new TreeCache());
+ treeCache.needUpdate = true;
+ checkScheduleAndInit();
+ return treeCache.doc;
+ } catch (Throwable e) {
+ LOG.info("LineEndCache catch Throwable but log to record.", e);
+ return null;
+ }
+ }
+
+ private static volatile boolean isRun = false;
+
+ private static void checkScheduleAndInit() {
+ if (!isRun) {
+ synchronized (TreeCacheUtils.class) {
+ if (!isRun) {
+ isRun = true;
+ AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay(() -> {
+ try {
+ ApplicationManager.getApplication().runReadAction(TreeCacheUtils::cacheUpdate);
+ } catch (Exception e) {
+ LOG.info("TreeCacheUtils checkScheduleAndInit catch Throwable but log to record.", e);
+ }
+ }, 0L, 1L, TimeUnit.SECONDS);
+ }
+ }
+ }
+ }
+
+ private static void cacheUpdate() {
+ cache.forEach((project, nodeCache) -> {
+ try {
+ if (project.isDisposed()) {
+ cache.remove(project);
+ return;
+ }
+ if (DumbService.isDumb(project)) {
+ return;
+ }
+ nodeCache.forEach((node, treeCache) -> {
+ try {
+ if (treeCache.needUpdate) {
+ treeCache.needUpdate = false;
+ treeCache.doc = Tree.treeDoc(node, project);
+ }
+ } catch (Exception e) {
+ LOG.info("TreeCacheUtils nodeCache.forEach catch Throwable but log to record.", e);
+ }
+ });
+ } catch (Exception e) {
+ LOG.info("TreeCacheUtils cache.forEach catch Throwable but log to record.", e);
+ }
+ });
+ }
+}
diff --git a/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java
index de260b1..9ed49c0 100644
--- a/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java
+++ b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ConfCache.java
@@ -4,7 +4,6 @@ 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;
import com.intellij.psi.search.FilenameIndex;
@@ -13,7 +12,11 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.regex.Pattern;
@@ -123,14 +126,16 @@ public class ConfCache {
new Task.Backgroundable(project, "Show Load xxx.tree/key/doc/json.tsv") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
+ indicator.setIndeterminate(false);
ApplicationManager.getApplication().runReadAction(() -> {
@NotNull Collection files = FilenameIndex.getAllFilesByExt(project, TsvLoader.EXT);
@NotNull StringBuilder sb = new StringBuilder();
- int i = 0;
+ double i = 0;
for (@NotNull VirtualFile file : files) {
indicator.setText(file.getName());
load(file);
- indicator.setFraction((double) ++i /files.size());
+ i++;
+ indicator.setFraction(i / files.size());
sb.append(file.getName()).append("\n");
}
if (files.isEmpty()) {
diff --git a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsComponent.java b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsComponent.java
index 0b64fe1..21e2236 100644
--- a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsComponent.java
+++ b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsComponent.java
@@ -17,20 +17,22 @@ public class AppSettingsComponent {
private final JPanel myMainPanel;
private final JBCheckBox showTreeComment = new JBCheckBox(ShowBundle.message("show.tree.comment"));
private final JBCheckBox compact = new JBCheckBox(ShowBundle.message("compact"));
+ private final JBCheckBox treeCache = new JBCheckBox(ShowBundle.message("tree.cache"));
private final JBTextField treeTags = new JBTextField();
private final JBCheckBox showLineEndComment = new JBCheckBox(ShowBundle.message("show.line.end.comment"));
- private final JBCheckBox showLineEndCommentJava = new JBCheckBox("Java ");
+ private final JBCheckBox lineEndCache = new JBCheckBox(ShowBundle.message("line.end.cache"));
+ private final JBCheckBox showLineEndCommentJava = new JBCheckBox(" Java ");
private final JBCheckBox showLineEndCommentJavaBase = new JBCheckBox("// Java ");
- private final JBCheckBox showLineEndCommentKotlin = new JBCheckBox("Kotlin ");
+ private final JBCheckBox showLineEndCommentKotlin = new JBCheckBox(" Kotlin ");
private final JBCheckBox showLineEndCommentKotlinBase = new JBCheckBox("// Kotlin ");
- private final JBCheckBox showLineEndCommentJs = new JBCheckBox("js ");
+ private final JBCheckBox showLineEndCommentJs = new JBCheckBox(" js ");
private final JBCheckBox showLineEndCommentJsBase = new JBCheckBox("// js ");
- private final JBCheckBox showLineEndCommentPy = new JBCheckBox("Python ");
+ private final JBCheckBox showLineEndCommentPy = new JBCheckBox(" Python ");
private final JBCheckBox showLineEndCommentPyBase = new JBCheckBox("# Python ");
- private final JBCheckBox showLineEndCommentGo = new JBCheckBox("Go ");
+ private final JBCheckBox showLineEndCommentGo = new JBCheckBox(" Go ");
private final JBCheckBox showLineEndCommentGoBase = new JBCheckBox("// Go ");
- private final JBCheckBox showLineEndCommentSql = new JBCheckBox("sql ");
- private final JBCheckBox showLineEndCommentJson = new JBCheckBox("json ");
+ private final JBCheckBox showLineEndCommentSql = new JBCheckBox(" sql ");
+ private final JBCheckBox showLineEndCommentJson = new JBCheckBox(" json ");
private final JBTextField lineTags = new JBTextField();
private final JBCheckBox getToSet = new JBCheckBox("get --> set ");
private final JBCheckBox fromNew = new JBCheckBox("java new ");
@@ -56,17 +58,18 @@ public class AppSettingsComponent {
@NotNull
private JPanel showPanel() {
JPanel comment = FormBuilder.createFormBuilder()
- .addComponent(JPanelFactory.of(showTreeComment, compact), 1)
- .addComponent(JPanelFactory.of(showLineEndComment,
+ .addComponent(JPanelFactory.of(showTreeComment, treeCache, compact), 1)
+ .addComponent(JPanelFactory.of(showLineEndComment, lineEndCache), 1)
+ .addComponent(JPanelFactory.of(
showLineEndCommentJava,
showLineEndCommentKotlin,
showLineEndCommentJs,
showLineEndCommentPy,
- showLineEndCommentGo
+ showLineEndCommentGo,
+ showLineEndCommentSql,
+ showLineEndCommentJson
), 1)
.addComponent(JPanelFactory.of(
- showLineEndCommentSql,
- showLineEndCommentJson,
showLineEndCommentJavaBase,
showLineEndCommentKotlinBase,
showLineEndCommentJsBase,
@@ -120,6 +123,14 @@ public class AppSettingsComponent {
compact.setSelected(newStatus);
}
+ public boolean getTreeCache() {
+ return treeCache.isSelected();
+ }
+
+ public void setTreeCache(boolean newStatus) {
+ treeCache.setSelected(newStatus);
+ }
+
@NotNull
public String getTreeTags() {
return treeTags.getText();
@@ -138,6 +149,14 @@ public class AppSettingsComponent {
showLineEndComment.setSelected(newStatus);
}
+ public boolean getLineEndCache() {
+ return lineEndCache.isSelected();
+ }
+
+ public void setLineEndCache(boolean newStatus) {
+ lineEndCache.setSelected(newStatus);
+ }
+
public boolean getShowLineEndCommentJava() {
return showLineEndCommentJava.isSelected();
}
diff --git a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsConfigurable.java b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsConfigurable.java
index 98cdd45..9edb0fd 100644
--- a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsConfigurable.java
+++ b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsConfigurable.java
@@ -37,8 +37,10 @@ public class AppSettingsConfigurable implements Configurable {
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
boolean modified = mySettingsComponent.getShowTreeComment() != settings.showTreeComment;
modified |= mySettingsComponent.getCompact() != settings.compact;
+ modified |= mySettingsComponent.getTreeCache() != settings.treeCache;
modified |= mySettingsComponent.getShowLineEndComment() != settings.showLineEndComment;
+ modified |= mySettingsComponent.getLineEndCache() != settings.lineEndCache;
modified |= mySettingsComponent.getShowLineEndCommentJava() != settings.showLineEndCommentJava;
modified |= mySettingsComponent.getShowLineEndCommentKotlin() != settings.showLineEndCommentKotlin;
modified |= mySettingsComponent.getShowLineEndCommentJs() != settings.showLineEndCommentJs;
@@ -73,8 +75,10 @@ public class AppSettingsConfigurable implements Configurable {
@NotNull AppSettingsState settings = AppSettingsState.getInstance();
settings.showTreeComment = mySettingsComponent.getShowTreeComment();
settings.compact = mySettingsComponent.getCompact();
+ settings.treeCache = mySettingsComponent.getTreeCache();
settings.showLineEndComment = mySettingsComponent.getShowLineEndComment();
+ settings.lineEndCache = mySettingsComponent.getLineEndCache();
settings.showLineEndCommentJava = mySettingsComponent.getShowLineEndCommentJava();
settings.showLineEndCommentKotlin = mySettingsComponent.getShowLineEndCommentKotlin();
settings.showLineEndCommentJs = mySettingsComponent.getShowLineEndCommentJs();
@@ -112,8 +116,10 @@ public class AppSettingsConfigurable implements Configurable {
static void reset(@NotNull AppSettingsState settings, @NotNull AppSettingsComponent mySettingsComponent) {
mySettingsComponent.setShowTreeComment(settings.showTreeComment);
mySettingsComponent.setCompact(settings.compact);
+ mySettingsComponent.setTreeCache(settings.treeCache);
mySettingsComponent.setShowLineEndComment(settings.showLineEndComment);
+ mySettingsComponent.setLineEndCache(settings.lineEndCache);
mySettingsComponent.setShowLineEndCommentJava(settings.showLineEndCommentJava);
mySettingsComponent.setShowLineEndCommentKotlin(settings.showLineEndCommentKotlin);
mySettingsComponent.setShowLineEndCommentJs(settings.showLineEndCommentJs);
diff --git a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsState.java b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsState.java
index ae1ba58..05b9e27 100644
--- a/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsState.java
+++ b/src/main/java/io/github/linwancen/plugin/show/settings/AppSettingsState.java
@@ -25,8 +25,10 @@ public class AppSettingsState implements PersistentStateComponent
+
+
diff --git a/src/main/resources/messages/ShowCommentBundle.properties b/src/main/resources/messages/ShowCommentBundle.properties
index d55db35..6a3a83a 100644
--- a/src/main/resources/messages/ShowCommentBundle.properties
+++ b/src/main/resources/messages/ShowCommentBundle.properties
@@ -4,8 +4,10 @@ reset.default=Reset default
show=Show
show.tree.comment=Show tree comment
compact=Support compact
+tree.cache=Tree Comment Cache
show.line.end.comment=Show line end comment
+line.end.cache=Line End Comment Cache for 2023.3 Slow EDT
only.select.line=Only Select Line
skip.anno=skip @
diff --git a/src/main/resources/messages/ShowCommentBundle_zh.properties b/src/main/resources/messages/ShowCommentBundle_zh.properties
index dbddceb..2c04e87 100644
--- a/src/main/resources/messages/ShowCommentBundle_zh.properties
+++ b/src/main/resources/messages/ShowCommentBundle_zh.properties
@@ -4,8 +4,10 @@ reset.default=\u6062\u590D\u9ED8\u8BA4
show=\u663E\u793A
show.tree.comment=\u663E\u793A\u6587\u4EF6\u6811\u6CE8\u91CA
compact=\u652F\u6301\u538B\u7F29\u7A7A\u7684\u4E2D\u95F4\u5305
+tree.cache=\u6587\u4EF6\u6811\u6CE8\u91CA\u7F13\u5B58
show.line.end.comment=\u663E\u793A\u884C\u672B\u6CE8\u91CA
+line.end.cache=\u884C\u672B\u6CE8\u91CA\u7F13\u5B58\u7528\u4E8E 2023.3 Slow EDT
only.select.line=\u53EA\u663E\u793A\u9009\u62E9\u884C
line.tags=\u884C\u6CE8\u91CA @ \u6807\u7B7E | \u5206\u9694