User: rednesto Date: 07 Jan 24 09:26 Revision: 42d5f7676fbd7db3af66cb75414af3113193bde0 Summary: Fix minecraft-dev/mcdev-error-report#1391 TeamCity URL: http://ci.mcdev.io:80/viewModification.html?tab=vcsModificationFiles&modId=8961&personal=false Index: src/main/kotlin/platform/mixin/inspection/addedMembers/AddedMembersNameFormatInspection.kt =================================================================== --- src/main/kotlin/platform/mixin/inspection/addedMembers/AddedMembersNameFormatInspection.kt (revision efc9e29c08c12e6bee67eb3acc5fc776f1fa5cc9) +++ src/main/kotlin/platform/mixin/inspection/addedMembers/AddedMembersNameFormatInspection.kt (revision 42d5f7676fbd7db3af66cb75414af3113193bde0) @@ -29,13 +29,13 @@ import com.demonwav.mcdev.util.toJavaIdentifier import com.intellij.codeInsight.CodeInsightBundle import com.intellij.codeInsight.FileModificationService +import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement import com.intellij.codeInspection.ProblemsHolder import com.intellij.icons.AllIcons import com.intellij.ide.util.SuperMethodWarningUtil import com.intellij.openapi.editor.Editor import com.intellij.openapi.module.Module -import com.intellij.openapi.project.DumbService import com.intellij.openapi.project.Project import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.ComponentValidator @@ -47,6 +47,7 @@ import com.intellij.psi.PsiMethod import com.intellij.psi.PsiNameIdentifierOwner import com.intellij.psi.PsiNamedElement +import com.intellij.psi.util.PsiTreeUtil import com.intellij.refactoring.rename.RenameProcessor import com.intellij.ui.DocumentAdapter import com.intellij.ui.EnumComboBoxModel @@ -300,29 +301,30 @@ if (isMethod) { val method = startElement as? PsiMethod ?: return if (editor != null) { - DumbService.getInstance(project).smartInvokeLater { - SuperMethodWarningUtil.checkSuperMethod(method, { md -> - RenameProcessor(project, md, newName, false, false).run() - true - }, editor) + SuperMethodWarningUtil.checkSuperMethod(method, { md -> + RenameProcessor(project, md, newName, false, false).run() + true + }, editor) - } } else { - DumbService.getInstance(project).smartInvokeLater { - val superMethod = method.findDeepestSuperMethods().firstOrNull() - for (md in listOfNotNull(superMethod, method)) { - RenameProcessor(project, md, newName, false, false).run() - } - } + val superMethod = method.findDeepestSuperMethods().firstOrNull() + for (md in listOfNotNull(superMethod, method)) { + RenameProcessor(project, md, newName, false, false).run() + } + } - } } else { if (!FileModificationService.getInstance().prepareFileForWrite(file)) { return } - DumbService.getInstance(project).smartInvokeLater { - RenameProcessor(project, startElement, newName, false, false).run() - } - } + RenameProcessor(project, startElement, newName, false, false).run() + } + } + + override fun generatePreview(project: Project, editor: Editor, file: PsiFile): IntentionPreviewInfo { + val element = PsiTreeUtil.findSameElementInCopy(startElement, file) + val target = element as? PsiNamedElement ?: return IntentionPreviewInfo.EMPTY + target.setName(newName) + return IntentionPreviewInfo.DIFF } - override fun startInWriteAction() = isMethod + override fun startInWriteAction() = false }