fix open other project clear ext doc cache | 修复打开其他项目时清空配置缓存

This commit is contained in:
林万程
2022-04-09 21:16:30 +08:00
parent feaaba2714
commit 28484823df
3 changed files with 28 additions and 3 deletions

View File

@@ -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<VirtualFile> 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");

View File

@@ -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
* <br>Use Reset only for file sort
*/
public class ResetExtDocAction extends AnAction {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
ConfCache.clearAll();
}
}

View File

@@ -92,5 +92,11 @@
text="🔄 // Reload External Comment">
<add-to-group group-id="ToolsMenu"/>
</action>
<action
id="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
class="io.github.linwancen.plugin.show.ext.conf.ResetExtDocAction"
text="🆑 // Clear External Comment">
<add-to-group group-id="ToolsMenu"/>
</action>
</actions>
</idea-plugin>