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 436678bacde..dc0e7f937f5 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 @@ -46,6 +46,7 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( val provider = ScratchFileLanguageProvider.get(psiFile.language) ?: return val handler = provider.getOutputHandler() + handler.onStart(scratchFile) log.printDebugMessage("Run Action: isMakeBeforeRun = $isMakeBeforeRun, isRepl = $isRepl") @@ -88,14 +89,16 @@ class RunScratchAction(private val scratchPanel: ScratchTopPanel) : AnAction( if (isMakeBeforeRun) { CompilerManager.getInstance(project).make(module) { aborted, errors, _, _ -> - if (!aborted && errors == 0) { - if (DumbService.isDumb(project)) { - DumbService.getInstance(project).smartInvokeLater { - executeScratch() - } - } else { + if (aborted || errors > 0) { + handler.error(scratchFile, "There were compilation errors in module ${module.name}") + } + + if (DumbService.isDumb(project)) { + DumbService.getInstance(project).smartInvokeLater { executeScratch() } + } else { + executeScratch() } } } else { diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/compile/KtCompilingExecutor.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/compile/KtCompilingExecutor.kt index c11bc39746c..b106c77acbd 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/compile/KtCompilingExecutor.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/compile/KtCompilingExecutor.kt @@ -52,8 +52,6 @@ import java.io.File class KtCompilingExecutor(file: ScratchFile) : ScratchExecutor(file) { override fun execute() { - handlers.forEach { it.onStart(file) } - val module = file.getModule() ?: return error("Module should be selected") val psiFile = file.getPsiFile() as? KtFile ?: return error("Couldn't find KtFile for current editor") diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt index b8fbf180db0..f970d4f6c58 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/repl/KtScratchReplExecutor.kt @@ -41,8 +41,6 @@ class KtScratchReplExecutor(file: ScratchFile) : ScratchExecutor(file) { private lateinit var osProcessHandler: OSProcessHandler override fun execute() { - handlers.forEach { it.onStart(file) } - val module = file.getModule() ?: return error(file, "Module should be selected") val cmdLine = KotlinConsoleKeeper.createCommandLine(module)