mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[qodana] QD-9717: quick fixes for IncorrectFormatting inspection
Change ReformatQuickFix from LocalQuickFix to ModCommandQuickFix, so it can be applied without the batch mode. (cherry picked from commit 5dacaf9f0c876fbdf72c295b607a22473df979e1) IJ-MR-149433 GitOrigin-RevId: 2b3f10d295d1939c875990295f1a8a5f078786e9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5c7fd97b96
commit
bc78caaaf4
+7
-5
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo.EMPTY
|
||||
import com.intellij.codeInspection.LocalQuickFix
|
||||
import com.intellij.codeInspection.ProblemDescriptor
|
||||
import com.intellij.lang.LangBundle
|
||||
import com.intellij.modcommand.*
|
||||
import com.intellij.openapi.editor.RangeMarker
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager
|
||||
@@ -47,13 +48,14 @@ class ReplaceQuickFix(val replacements: List<Pair<RangeMarker, CharSequence>>) :
|
||||
|
||||
|
||||
@ApiStatus.Internal
|
||||
object ReformatQuickFix : LocalQuickFix {
|
||||
object ReformatQuickFix : ModCommandQuickFix() {
|
||||
override fun getFamilyName(): @Nls String = LangBundle.message("inspection.incorrect.formatting.fix.reformat")
|
||||
|
||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||
val innerFile = descriptor.psiElement.containingFile
|
||||
val file = innerFile.viewProvider.run { getPsi(baseLanguage) }
|
||||
CodeStyleManager.getInstance(project).reformatText(file, 0, file.textLength)
|
||||
override fun perform(project: Project, descriptor: ProblemDescriptor): ModCommand {
|
||||
return ModCommand.psiUpdate(descriptor.psiElement.containingFile) { mutableFile: PsiFile, _: ModPsiUpdater ->
|
||||
val file = mutableFile.viewProvider.getPsi(mutableFile.viewProvider.baseLanguage)
|
||||
CodeStyleManager.getInstance(project).reformatText(file, 0, file.textLength)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user