From 02fa8b5bab2e26f1822d383af9d28888699ccfc1 Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Thu, 10 May 2018 14:35:17 +0300 Subject: [PATCH] Check for dumb mode before compiling scratch file ^KT-23560 --- .../idea/scratch/actions/RunScratchAction.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt index 57e5a35d9e9..0e66a452ef4 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/actions/RunScratchAction.kt @@ -20,6 +20,7 @@ import com.intellij.icons.AllIcons import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.compiler.CompilerManager +import com.intellij.openapi.project.DumbService import org.jetbrains.kotlin.idea.KotlinBundle import org.jetbrains.kotlin.idea.scratch.ScratchFile import org.jetbrains.kotlin.idea.scratch.ScratchFileLanguageProvider @@ -55,7 +56,7 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( return } - val runnable = r@ { + val runnable = r@{ val executor = if (isRepl) provider.createReplExecutor(scratchFile) else provider.createCompilingExecutor(scratchFile) if (executor == null) { handler.error(scratchFile, "Couldn't run ${psiFile.name}") @@ -82,12 +83,22 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( e.presentation.isEnabled = true log.error(ex) + return@r } } if (isMakeBeforeRun) { - CompilerManager.getInstance(project) - .make(module) { aborted, errors, _, _ -> if (!aborted && errors == 0) runnable() } + CompilerManager.getInstance(project).make(module) { aborted, errors, _, _ -> + if (!aborted && errors == 0) { + if (DumbService.isDumb(project)) { + DumbService.getInstance(project).smartInvokeLater { + runnable() + } + } else { + runnable() + } + } + } } else { runnable() }