Fix IndexNotReadyException during runnning scratch file in Android Studio

This commit is contained in:
Natalia Selezneva
2018-12-06 14:58:39 +03:00
parent 84aef9cf2d
commit 62584f2483
@@ -23,7 +23,9 @@ import com.intellij.openapi.compiler.ex.CompilerPathsEx
import com.intellij.openapi.module.Module import com.intellij.openapi.module.Module
import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.Task import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.roots.OrderEnumerator import com.intellij.openapi.roots.OrderEnumerator
import com.intellij.openapi.util.Computable
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.codegen.ClassBuilderFactories import org.jetbrains.kotlin.codegen.ClassBuilderFactories
@@ -77,7 +79,11 @@ class KtCompilingExecutor(file: ScratchFile) : ScratchExecutor(file) {
} }
try { try {
val tempDir = runReadAction { compileFileToTempDir(modifiedScratchSourceFile) } ?: return val tempDir = DumbService.getInstance(project).runReadActionInSmartMode(
Computable {
compileFileToTempDir(modifiedScratchSourceFile)
}
) ?: return
try { try {
val commandLine = createCommandLine(module, result.mainClassName, tempDir.path) val commandLine = createCommandLine(module, result.mainClassName, tempDir.path)