tree external doc conf ignore ext | 文件夹注释配置忽略拓展名

This commit is contained in:
林万程
2022-04-09 23:13:41 +08:00
parent 63303a39da
commit 595d3730d4
4 changed files with 46 additions and 16 deletions

View File

@@ -51,17 +51,17 @@ public class ConfCache {
// faster than find in KEY_CACHE
return Collections.emptyMap();
}
return ConfCacheGetUtils.get(file, KEY_MID_EXT, KEY_CACHE);
return ConfCacheGetUtils.filterPathNameExt(file, KEY_MID_EXT, KEY_CACHE);
}
@NotNull
public static Map<String, Map<String, List<String>>> docMap(@Nullable Project project, @NotNull VirtualFile file) {
return ConfCacheGetUtils.get(file, DOC_MID_EXT, DOC_CACHE);
return ConfCacheGetUtils.filterPathNameExt(file, DOC_MID_EXT, DOC_CACHE);
}
@NotNull
public static Map<String, Map<String, List<String>>> treeMap(@Nullable Project project, @NotNull VirtualFile file) {
return ConfCacheGetUtils.get(file, TREE_MID_EXT, TREE_CACHE);
return ConfCacheGetUtils.filterPath(file, TREE_CACHE);
}
static void clearAll() {

View File

@@ -28,15 +28,12 @@ class ConfCacheGetUtils {
* @return {@code <sortKey, T>}
*/
@NotNull
static <T> TreeMap<String, T> get(@NotNull VirtualFile file,
@NotNull String confMidExt,
@NotNull Map<VirtualFile, T> cache) {
static <T> TreeMap<String, T> filterPathNameExt(@NotNull VirtualFile file,
@NotNull String confMidExt,
@NotNull Map<VirtualFile, T> cache) {
String path = file.getPath();
String name = file.getName();
String ext = file.getExtension();
if (ext == null) {
ext = "";
}
TreeMap<String, T> map = new TreeMap<>();
int max = path.length();
int length = String.valueOf(max).length();
@@ -53,15 +50,48 @@ class ConfCacheGetUtils {
map.put(levelStr + "\b" + confPath, entry.getValue());
} else if (confName.endsWith((name + confMidExt))) {
map.put(levelStr + "\t" + confPath, entry.getValue());
} else if ((ext + confMidExt).equals(confName)) {
map.put(levelStr + "\n" + confPath, entry.getValue());
} else if (confName.endsWith((ext + confMidExt))) {
map.put(levelStr + "\f" + confPath, entry.getValue());
} else if (ext != null) {
if ((ext + confMidExt).equals(confName)) {
map.put(levelStr + "\n" + confPath, entry.getValue());
} else if (confName.endsWith((ext + confMidExt))) {
map.put(levelStr + "\f" + confPath, entry.getValue());
}
}
}
return map;
}
/**
* <br>file:
* <br>a/b/c.ext
* <br>
* <br>configure file priority:
* <br>a/b/any.tree.tsv
* <br>a/any.tree.tsv
*
* @return {@code <sortKey, T>}
*/
@NotNull
static <T> TreeMap<String, T> filterPath(@NotNull VirtualFile file,
@SuppressWarnings("SameParameterValue")
@NotNull Map<VirtualFile, T> cache) {
String path = file.getPath();
TreeMap<String, T> map = new TreeMap<>();
int max = path.length();
int length = String.valueOf(max).length();
for (Map.Entry<VirtualFile, T> entry : cache.entrySet()) {
VirtualFile confFile = entry.getKey();
String confPath = confFile.getPath();
int level = level(path, confPath);
if (level == 0) {
continue;
}
String levelStr = StringUtils.leftPad(String.valueOf(max - level), length, '0');
map.put(levelStr + confPath, entry.getValue());
}
return map;
}
private static int level(String path, String confPath) {
path = srcPath(path);
confPath = srcPath(confPath);

View File

@@ -2,7 +2,7 @@ COBOL-file.tsv.tree.tsv 📝 COBOL 相关文件注释
COBOL.cbl.key.tsv COBOL 必要【关键字】
COBOL-struct.cbl.doc.tsv COBOL 文件结构【关键字】
COBOL-struct.cbl.doc.tsv COBOL 文件结构
COBOL-data.cbl.key.tsv COBOL 数据部必要【关键字】
COBOL-data-layout.cbl.key.tsv COBOL 数据布局【关键字】
@@ -17,4 +17,4 @@ COBOL-loop.cbl.key.tsv COBOL 循环【关键字】(非必要)
COBOL-string.cbl.key.tsv COBOL 字符串【关键字】(非必要)
COBOL_IDEA.md COBOL IDEA 高亮设置
COBOL_keyword1.md COBOL COBOL IDEA 高亮 普通关键字
COBOL_keyword1.md COBOL IDEA 高亮 普通关键字
1 COBOL-file.tsv.tree.tsv 📝 COBOL 相关文件注释
2 COBOL.cbl.key.tsv COBOL 必要【关键字】
3 COBOL-struct.cbl.doc.tsv COBOL 文件结构【关键字】 COBOL 文件结构
4 COBOL-data.cbl.key.tsv COBOL 数据部必要【关键字】
5 COBOL-data-layout.cbl.key.tsv COBOL 数据布局【关键字】
6 COBOL-data-type.cbl.key.tsv COBOL 数据类型【关键字】
7 COBOL-compute.cbl.key.tsv COBOL 算数符号【关键字】
8 COBOL-compute-word.cbl.key.tsv COBOL 算数词汇【关键字】
17
18
19
20

View File

@@ -1,4 +1,4 @@
# IDEA COBOL 高亮配置
# COBOL IDEA 高亮配置
- File -> Settings -> Editor -> File Types
- 文件 -> 设置 -> 编辑器 -> 文件类型