Fix IndexNotReadyException during runnning scratch file in Android Studio
This commit is contained in:
@@ -23,7 +23,9 @@ import com.intellij.openapi.compiler.ex.CompilerPathsEx
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.DumbService
|
||||
import com.intellij.openapi.roots.OrderEnumerator
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderFactories
|
||||
@@ -77,7 +79,11 @@ class KtCompilingExecutor(file: ScratchFile) : ScratchExecutor(file) {
|
||||
}
|
||||
|
||||
try {
|
||||
val tempDir = runReadAction { compileFileToTempDir(modifiedScratchSourceFile) } ?: return
|
||||
val tempDir = DumbService.getInstance(project).runReadActionInSmartMode(
|
||||
Computable {
|
||||
compileFileToTempDir(modifiedScratchSourceFile)
|
||||
}
|
||||
) ?: return
|
||||
|
||||
try {
|
||||
val commandLine = createCommandLine(module, result.mainClassName, tempDir.path)
|
||||
|
||||
Reference in New Issue
Block a user