From 76b5eadbaab90058b16fc8fac892ffb6ad3b3a8b Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 7 Dec 2016 19:41:15 +0300 Subject: [PATCH] Mark file writable before creating intention delegate (change of writable property can increment out-of-code-block modification count, which recreates the cached resolve session) --- .../kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt index ffab4cdb897..e8de437a614 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixWithDelegateFactory.kt @@ -16,6 +16,7 @@ package org.jetbrains.kotlin.idea.quickfix +import com.intellij.codeInsight.FileModificationService import com.intellij.codeInsight.intention.HighPriorityAction import com.intellij.codeInsight.intention.IntentionAction import com.intellij.codeInsight.intention.LowPriorityAction @@ -49,6 +50,10 @@ open class QuickFixWithDelegateFactory( override fun startInWriteAction() = startInWriteAction override fun invoke(project: Project, editor: Editor?, file: PsiFile?) { + if (!FileModificationService.getInstance().prepareFileForWrite(file)) { + return + } + val action = delegateFactory() ?: return assert(action.detectPriority() == this.detectPriority()) {