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)

This commit is contained in:
Dmitry Jemerov
2016-12-07 19:41:15 +03:00
parent 16e648e333
commit 76b5eadbaa
@@ -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()) {