From 647ef8b195d414da3a3eed21e76adb80901afdc6 Mon Sep 17 00:00:00 2001 From: Tomasz Pasternak Date: Wed, 11 Dec 2024 16:05:23 +0100 Subject: [PATCH] fix: IndexNotReadyException during 'Enable Analysis' (#7150) * fix: IndexNotReadyException during 'Enable Analysis' closes #7142 * No more need to declare IOException --- .../java/qsync/GeneratedSourcesStripper.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/java/src/com/google/idea/blaze/java/qsync/GeneratedSourcesStripper.java b/java/src/com/google/idea/blaze/java/qsync/GeneratedSourcesStripper.java index 6369d60d7e4..cf8366865ac 100644 --- a/java/src/com/google/idea/blaze/java/qsync/GeneratedSourcesStripper.java +++ b/java/src/com/google/idea/blaze/java/qsync/GeneratedSourcesStripper.java @@ -27,7 +27,9 @@ import com.intellij.lang.jvm.annotation.JvmAnnotationAttribute; import com.intellij.lang.jvm.annotation.JvmAnnotationConstantValue; import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.ThrowableComputable; import com.intellij.psi.PsiAnnotation; import com.intellij.psi.PsiClass; @@ -137,10 +139,18 @@ private void removeSourcesWithMatchingAnnotations(CachedArtifact src, Path dest) @Nullable @VisibleForTesting - String getGeneratedValue(String fileName, ByteSource content) throws IOException { + String getGeneratedValue(String fileName, ByteSource content) { return ApplicationManager.getApplication() - .runReadAction( - (ThrowableComputable) () -> getInReadAction(fileName, content)); + .runReadAction( + (Computable) () -> + DumbService.getInstance(project).tryRunReadActionInSmartMode( + () -> { + try { + return getInReadAction(fileName, content); + } catch (IOException e) { + throw new RuntimeException(e); + } + }, "%s waiting for Smart Mode".formatted(GeneratedSourcesStripper.class.getSimpleName()))); } /**