add missing prepareForWrite() calls
This commit is contained in:
+2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.inspections
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInsight.intention.HighPriorityAction
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
@@ -167,6 +168,7 @@ abstract class IntentionBasedInspection<TElement : PsiElement>(
|
||||
override fun invoke(project: Project, file: PsiFile, startElement: PsiElement, endElement: PsiElement) {
|
||||
assert(startElement == endElement)
|
||||
if (!isAvailable(project, file, startElement, endElement)) return
|
||||
if (!FileModificationService.getInstance().prepareFileForWrite(file)) return
|
||||
|
||||
val editor = startElement.findExistingEditor()
|
||||
editor?.caretModel?.moveToOffset(startElement.textOffset)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.codeInspection.LocalInspectionEP
|
||||
@@ -104,6 +105,7 @@ abstract class SelfTargetingIntention<TElement : PsiElement>(
|
||||
final override fun invoke(project: Project, editor: Editor, file: PsiFile): Unit {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments()
|
||||
val target = getTarget(editor, file) ?: return
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(target)) return
|
||||
applyTo(target, editor)
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.kdoc
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInspection.LocalQuickFix
|
||||
import com.intellij.codeInspection.ProblemDescriptor
|
||||
import com.intellij.codeInspection.ProblemsHolder
|
||||
@@ -69,6 +70,7 @@ class KDocMissingDocumentationInspection(): AbstractKotlinInspection() {
|
||||
override fun getFamilyName(): String = name
|
||||
|
||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(descriptor.psiElement)) return
|
||||
val declaration = descriptor.psiElement.getParentOfType<KtNamedDeclaration>(true)
|
||||
?: throw IllegalStateException("Can't find declaration")
|
||||
declaration.addBefore(KDocElementFactory(project).createKDocFromText("/** */"), declaration.firstChild)
|
||||
|
||||
+3
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.quickfix
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInspection.SuppressIntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
@@ -47,6 +48,8 @@ class KotlinSuppressIntentionAction private constructor(
|
||||
override fun isAvailable(project: Project, editor: Editor?, element: PsiElement) = element.isValid
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, element: PsiElement) {
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return
|
||||
|
||||
val id = "\"$suppressKey\""
|
||||
when (suppressAt) {
|
||||
is KtModifierListOwner ->
|
||||
|
||||
Reference in New Issue
Block a user