fix: valid file and dir
This commit is contained in:
@@ -67,16 +67,20 @@ public class LineEndCacheUtils {
|
||||
|
||||
private static void cacheUpdate(Project project, Map<VirtualFile, Map<Integer, LineEndCache>> fileMap) {
|
||||
try {
|
||||
fileMap.forEach((file, lineMap) -> lineMap.forEach((lineNumber, lineCache) -> {
|
||||
if (project.isDisposed() || DumbService.isDumb(project)) {
|
||||
return;
|
||||
}
|
||||
fileMap.forEach((file, lineMap) -> {
|
||||
if (!file.isValid()) {
|
||||
return;
|
||||
}
|
||||
lineMap.forEach((lineNumber, lineCache) -> {
|
||||
@NotNull LineInfo info = lineCache.info;
|
||||
@Nullable List<LineExtensionInfo> list = lineCache.map.get(info.text);
|
||||
if (!(lineCache.needUpdate() || list == null)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (project.isDisposed() || DumbService.isDumb(project) || !file.isValid()) {
|
||||
return;
|
||||
}
|
||||
@Nullable LineExtensionInfo lineExt = LineEnd.lineExt(info);
|
||||
@Nullable LineInfo info2 = LineInfo.of(info, lineNumber);
|
||||
if (info2 == null || !info2.text.equals(info.text)) {
|
||||
@@ -106,7 +110,8 @@ public class LineEndCacheUtils {
|
||||
LOG.info("LineEndCacheUtils lineMap.forEach catch Throwable but log to record.", e);
|
||||
}
|
||||
}
|
||||
}));
|
||||
});
|
||||
});
|
||||
} catch (ProcessCanceledException ignored) {
|
||||
} catch (IllegalStateException ignore) {
|
||||
// ignore inSmartMode(project) throw:
|
||||
|
||||
@@ -41,7 +41,7 @@ public class XmlLangDoc extends BaseLangDoc {
|
||||
public @Nullable <T extends SettingsInfo> String treeDoc(@NotNull T info, @NotNull ProjectViewNode<?> node,
|
||||
@NotNull Project project) {
|
||||
@Nullable VirtualFile virtualFile = node.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
if (virtualFile == null || virtualFile.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
@Nullable FileViewProvider viewProvider = PsiManager.getInstance(project).findViewProvider(virtualFile);
|
||||
|
||||
@@ -59,7 +59,13 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
if (viewProvider == null) {
|
||||
return null;
|
||||
}
|
||||
@Nullable PsiElement element = viewProvider.findElementAt(info.endOffset);
|
||||
@Nullable PsiElement element;
|
||||
try {
|
||||
element = viewProvider.findElementAt(info.endOffset);
|
||||
} catch (Throwable ignored) {
|
||||
// InvalidVirtualFileAccessException
|
||||
return null;
|
||||
}
|
||||
if (element == null) {
|
||||
// file end
|
||||
element = viewProvider.findElementAt(info.endOffset - 1);
|
||||
@@ -177,6 +183,9 @@ public abstract class BaseLangDoc extends EditorLinePainter {
|
||||
public static @Nullable <T extends SettingsInfo> String resolveDoc(@NotNull T info,
|
||||
@NotNull PsiElement psiElement) {
|
||||
try {
|
||||
if (!psiElement.isValid()) {
|
||||
return null;
|
||||
}
|
||||
// byte to src
|
||||
PsiElement navElement = psiElement.getNavigationElement();
|
||||
if (navElement != null) {
|
||||
|
||||
Reference in New Issue
Block a user