From 3757083de8c8d5a1c0b2ff882cac4af5b06e5d01 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 30 Sep 2025 12:39:59 +0200 Subject: [PATCH] [java-decompiler] fix deprecation warnings and minor style lints GitOrigin-RevId: 3dacc55169d075ec2ab70cd3345bc4316f13fa75 --- .../java/decompiler/DecompilerInEditorListener.kt | 15 ++++++++------- .../java/decompiler/ShowDecompiledClassAction.kt | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/DecompilerInEditorListener.kt b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/DecompilerInEditorListener.kt index 7988ffdc11bb..36ea1a159db1 100644 --- a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/DecompilerInEditorListener.kt +++ b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/DecompilerInEditorListener.kt @@ -14,6 +14,7 @@ import com.intellij.openapi.editor.impl.EditorImpl import com.intellij.openapi.editor.impl.EditorInspectionsActionToolbar import com.intellij.openapi.editor.impl.EditorMarkupModelImpl import com.intellij.openapi.editor.impl.EditorToolbarButtonLook +import com.intellij.openapi.fileEditor.FileDocumentManager import com.intellij.ui.components.JBScrollPane import com.intellij.ui.components.panels.NonOpaquePanel import com.intellij.util.ui.JBInsets @@ -26,9 +27,9 @@ import kotlin.math.max private class DecompilerInEditorListener : EditorFactoryListener { override fun editorCreated(event: EditorFactoryEvent) { val editor = event.editor as? EditorImpl ?: return - val file = editor.virtualFile ?: return - if (file.fileType != JavaClassFileType.INSTANCE) return - if (file.name == "module-info.class") return + val virtualFile = FileDocumentManager.getInstance().getFile(editor.document) ?: return + if (virtualFile.fileType != JavaClassFileType.INSTANCE) return + if (virtualFile.name == "module-info.class") return setupModeToggles(editor) } @@ -77,17 +78,17 @@ private class DecompilerInEditorListener : EditorFactoryListener { val toolbar = statusToolbar.component toolbar.layout = EditorMarkupModelImpl.StatusComponentLayout() - toolbar.setBorder(JBUI.Borders.empty(2)) + toolbar.border = JBUI.Borders.empty(2) val statusPanel = NonOpaquePanel() statusPanel.isVisible = true - statusPanel.setLayout(BoxLayout(statusPanel, BoxLayout.X_AXIS)) + statusPanel.layout = BoxLayout(statusPanel, BoxLayout.X_AXIS) statusPanel.add(toolbar) - val scrollPane = (editor.scrollPane as? JBScrollPane) ?: return + val scrollPane = editor.scrollPane as? JBScrollPane ?: return scrollPane.statusComponent = statusPanel - val scrollPaneLayout = (scrollPane.layout as? JBScrollPane.Layout) ?: return + val scrollPaneLayout = scrollPane.layout as? JBScrollPane.Layout ?: return scrollPaneLayout.syncWithScrollPane(scrollPane) } } diff --git a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/ShowDecompiledClassAction.kt b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/ShowDecompiledClassAction.kt index 072dd3da9fe7..17a77dc79959 100644 --- a/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/ShowDecompiledClassAction.kt +++ b/plugins/java-decompiler/plugin/src/org/jetbrains/java/decompiler/ShowDecompiledClassAction.kt @@ -17,7 +17,7 @@ import com.intellij.psi.util.PsiUtilBase class ShowDecompiledClassAction : AnAction(IdeaDecompilerBundle.message("action.show.decompiled.name")) { - override fun getActionUpdateThread() = ActionUpdateThread.BGT + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT override fun update(e: AnActionEvent) { val psiElement = getPsiElement(e)