From 28484823df86330909b20f6265b38f562d98102a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=B8=87=E7=A8=8B?= <1498425439@qq.com> Date: Sat, 9 Apr 2022 21:16:30 +0800 Subject: [PATCH] =?UTF-8?q?fix=20open=20other=20project=20clear=20ext=20do?= =?UTF-8?q?c=20cache=20|=20=E4=BF=AE=E5=A4=8D=E6=89=93=E5=BC=80=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E9=A1=B9=E7=9B=AE=E6=97=B6=E6=B8=85=E7=A9=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/show/ext/conf/ConfCache.java | 9 ++++++--- .../plugin/show/ext/conf/ResetExtDocAction.java | 16 ++++++++++++++++ src/main/resources/META-INF/plugin.xml | 6 ++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/main/java/io/github/linwancen/plugin/show/ext/conf/ResetExtDocAction.java 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 3fc5196..53c9a7b 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 @@ -59,6 +59,12 @@ public class ConfCache { return ConfCacheGetUtils.get(file, TREE_MID_EXT, TREE_CACHE); } + static void clearAll() { + KEY_CACHE.clear(); + DOC_CACHE.clear(); + TREE_CACHE.clear(); + } + static void remove(@NotNull VirtualFile file, String name) { if (name != null) { int i = name.lastIndexOf('.'); @@ -102,9 +108,6 @@ public class ConfCache { DumbService.getInstance(project).runReadActionInSmartMode(() -> { Collection files = FilenameIndex.getAllFilesByExt(project, EXT); StringBuilder sb = new StringBuilder(); - KEY_CACHE.clear(); - DOC_CACHE.clear(); - TREE_CACHE.clear(); for (VirtualFile file : files) { load(project, file); sb.append(file.getPath()).append("\n"); diff --git a/src/main/java/io/github/linwancen/plugin/show/ext/conf/ResetExtDocAction.java b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ResetExtDocAction.java new file mode 100644 index 0000000..a8ed469 --- /dev/null +++ b/src/main/java/io/github/linwancen/plugin/show/ext/conf/ResetExtDocAction.java @@ -0,0 +1,16 @@ +package io.github.linwancen.plugin.show.ext.conf; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import org.jetbrains.annotations.NotNull; + +/** + * call ConfCache.clearAll + *
Use Reset only for file sort + */ +public class ResetExtDocAction extends AnAction { + @Override + public void actionPerformed(@NotNull AnActionEvent e) { + ConfCache.clearAll(); + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 8a5894f..fc114be 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -92,5 +92,11 @@ text="🔄 // Reload External Comment"> + + + \ No newline at end of file