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
This commit is contained in:
Natalia Selezneva
2019-06-03 16:24:58 +03:00
parent ab0877390b
commit 7038d9b8db
2 changed files with 1 additions and 25 deletions
@@ -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)
}
}
@@ -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<Long>("CRC_WITHOUT_SPACES"))