tree external doc conf ignore ext | 文件夹注释配置忽略拓展名
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user