User: rednesto Date: 06 Oct 24 15:44 Revision: 017a3e92967da678f12d1f2ed4b76f328dee8869 Summary: Merge branch '2024.1' into 2024.2 TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9774&personal=false Index: gradle.properties =================================================================== --- gradle.properties (revision 69a1bddc04c0bdf4e357693428d4506be7cc7fc8) +++ gradle.properties (revision 017a3e92967da678f12d1f2ed4b76f328dee8869) @@ -21,7 +21,7 @@ # suppress inspection "UnusedProperty" for whole file ideaVersionName = 2024.2 -coreVersion = 1.8.1 +coreVersion = 1.8.2 # Silences a build-time warning because we are bundling our own kotlin library kotlin.stdlib.default.dependency = false Index: src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt =================================================================== --- src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt (revision 69a1bddc04c0bdf4e357693428d4506be7cc7fc8) +++ src/main/kotlin/platform/mixin/inspection/injector/InvalidInjectorMethodSignatureInspection.kt (revision 017a3e92967da678f12d1f2ed4b76f328dee8869) @@ -330,16 +330,17 @@ } val method = startElement as PsiMethod fixParameters(project, method.parameterList, false) - fixReturnType(method) - fixIntLikeTypes(method, editor ?: return) + fixReturnType(method, editor ?: return, file, false) + fixIntLikeTypes(method, editor, false) } override fun generatePreview(project: Project, editor: Editor, file: PsiFile): IntentionPreviewInfo { val method = PsiTreeUtil.findSameElementInCopy(startElement, file) as? PsiMethod ?: return IntentionPreviewInfo.EMPTY fixParameters(project, method.parameterList, true) - fixReturnType(method) - fixIntLikeTypes(method, editor) + // Pass the original startElement because the underlying fix gets the preview element itself + fixReturnType(startElement as PsiMethod, editor, file, true) + fixIntLikeTypes(method, editor, true) return IntentionPreviewInfo.DIFF } @@ -386,36 +387,45 @@ } } - private fun fixReturnType(method: PsiMethod) { + private fun fixReturnType(method: PsiMethod, editor: Editor, file: PsiFile, preview: Boolean) { if (expectedReturnType == null) { return } - QuickFixFactory.getInstance() - .createMethodReturnFix(method, expectedReturnType, false) - .applyFix() + val fix = QuickFixFactory.getInstance().createMethodReturnFix(method, expectedReturnType, false) + if (preview) { + fix.generatePreview(file.project, editor, file) + } else { + fix.applyFix() - } + } + } - private fun fixIntLikeTypes(method: PsiMethod, editor: Editor) { + private fun fixIntLikeTypes(method: PsiMethod, editor: Editor, preview: Boolean) { if (intLikeTypePositions.isEmpty()) { return } - invokeLater { - WriteCommandAction.runWriteCommandAction( - method.project, - "Choose Int-Like Type", - null, - { + val runnable = { - val template = makeIntLikeTypeTemplate(method, intLikeTypePositions) - if (template != null) { - editor.caretModel.moveToOffset(method.startOffset) - TemplateManager.getInstance(method.project) - .startTemplate(editor, template) - } + val template = makeIntLikeTypeTemplate(method, intLikeTypePositions) + if (template != null) { + editor.caretModel.moveToOffset(method.startOffset) + TemplateManager.getInstance(method.project) + .startTemplate(editor, template) + } - }, + } + + if (preview) { + runnable() + } else { + invokeLater { + WriteCommandAction.runWriteCommandAction( + method.project, + "Choose Int-Like Type", + null, + runnable, - method.parentOfType()!! - ) - } - } + method.parentOfType()!! + ) + } + } + } private fun makeIntLikeTypeTemplate( method: PsiMethod,