From 7038d9b8db5f4b7c346fb5b8a1ded1702db2be4f Mon Sep 17 00:00:00 2001 From: Natalia Selezneva Date: Mon, 3 Jun 2019 16:24:58 +0300 Subject: [PATCH] Do not use ConfigurationFileCrcFactory comparing scratch content because it needed the document to be saved Check only if new fragment is not empty to avoid recompilation on minor changes --- .../idea/scratch/ScratchFileAutoRunner.kt | 2 +- .../kotlin/idea/scratch/scratchRunnerUtil.kt | 24 ------------------- 2 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/scratchRunnerUtil.kt diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileAutoRunner.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileAutoRunner.kt index 9aa3a3ffdba..f141f85c311 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileAutoRunner.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/ScratchFileAutoRunner.kt @@ -45,7 +45,7 @@ class ScratchFileAutoRunner(private val project: Project) : DocumentListener { val panel = getScratchPanel(file, project) ?: return if (!panel.scratchFile.options.isInteractiveMode) return - if (isScratchChanged(project, file)) { + if (!event.newFragment.isBlank()) { runScratch(panel) } } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/scratchRunnerUtil.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/scratchRunnerUtil.kt deleted file mode 100644 index fe7582590ba..00000000000 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/scratch/scratchRunnerUtil.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.idea.scratch - -import com.intellij.openapi.externalSystem.service.project.autoimport.ConfigurationFileCrcFactory -import com.intellij.openapi.project.Project -import com.intellij.openapi.util.Key -import com.intellij.openapi.vfs.VirtualFile -import org.jetbrains.kotlin.psi.UserDataProperty - -fun isScratchChanged(project: Project, file: VirtualFile) : Boolean { - val beforeLastRun = file.crcWithoutSpaces - val newCrc = ConfigurationFileCrcFactory(project, file).create() - if (beforeLastRun != newCrc) { - file.crcWithoutSpaces = newCrc - return true - } - return false -} - -private var VirtualFile.crcWithoutSpaces by UserDataProperty(Key.create("CRC_WITHOUT_SPACES")) \ No newline at end of file