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()))); } /**