pref: Vue src/router tree doc runReadAction slow and lineEnd Cache update sync

This commit is contained in:
林万程
2025-02-19 07:45:56 +08:00
parent ba6ded4d44
commit d6d7d85c5a
2 changed files with 22 additions and 22 deletions

View File

@@ -91,18 +91,18 @@ public class LineEndCacheUtils {
private static void cacheUpdate() {
cache.forEach((project, fileMap) -> {
try {
if (project.isDisposed()) {
cache.remove(project);
return;
}
fileMap.forEach((file, lineMap) -> lineMap.forEach((lineNumber, lineCache) -> {
@NotNull LineInfo info = lineCache.info;
@Nullable List<LineExtensionInfo> list = lineCache.map.get(info.text);
if (!(lineCache.needUpdate() || list == null)) {
ReadAction.nonBlocking(() -> {
try {
if (project.isDisposed()) {
cache.remove(project);
return;
}
ReadAction.nonBlocking(() -> {
fileMap.forEach((file, lineMap) -> 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)) {
return;
@@ -137,15 +137,16 @@ public class LineEndCacheUtils {
LOG.info("LineEndCacheUtils lineMap.forEach catch Throwable but log to record.", e);
}
}
}).inSmartMode(project).executeSynchronously();
}));
} catch (ProcessCanceledException ignored) {
} catch (IllegalStateException ignore) {
// ignore inSmartMode(project) throw:
// @NotNull method com/intellij/openapi/project/impl/ProjectImpl.getEarlyDisposable must not return null
} catch (Throwable e) {
LOG.info("LineEndCacheUtils cache.forEach catch Throwable but log to record.", e);
}
}));
} catch (ProcessCanceledException ignored) {
} catch (IllegalStateException ignore) {
// ignore inSmartMode(project) throw:
// @NotNull method com/intellij/openapi/project/impl/ProjectImpl.getEarlyDisposable must not
// return null
} catch (Throwable e) {
LOG.info("LineEndCacheUtils cache.forEach catch Throwable but log to record.", e);
}
}).inSmartMode(project).submit(AppExecutorUtil.getAppExecutorService());
});
}
}

View File

@@ -46,9 +46,8 @@ public abstract class FileLoader {
public void loadAll(@NotNull Project project) {
ApplicationManager.getApplication().executeOnPooledThread(() ->
DumbService.getInstance(project).runReadActionInSmartMode(() ->
ApplicationManager.getApplication().runReadAction(() ->
loadAllImpl(project))));
DumbService.getInstance(project).runReadActionInSmartMode(()
-> loadAllImpl(project)));
}
void loadFile(@NotNull VirtualFile file, @Nullable Project project) {