Skip to content

Commit

Permalink
fix: IndexNotReadyException during 'Enable Analysis' (#7150)
Browse files Browse the repository at this point in the history
* fix: IndexNotReadyException during 'Enable Analysis'

closes #7142

* No more need to declare IOException
  • Loading branch information
Tomasz Pasternak authored Dec 11, 2024
1 parent f9af31b commit 647ef8b
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, IOException>) () -> getInReadAction(fileName, content));
.runReadAction(
(Computable<String>) () ->
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())));
}

/**
Expand Down

0 comments on commit 647ef8b

Please sign in to comment.