From 812cf8a8911dafca953b78d36eae1539d11f5284 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 4 Nov 2025 11:38:01 +0100 Subject: [PATCH] Revert "[java-decompiler] format DecompilerInEditorListener" This reverts commit 95944d138ca7ad71d0a5d4aa686b3dc42c535ef6. GitOrigin-RevId: aae55272a9ba6275043cb6d3875f0ae176b6d603 --- .../decompiler/DecompilerInEditorListener.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 d33e8aa24670..227a6f683de0 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 @@ -9,6 +9,7 @@ import com.intellij.openapi.actionSystem.Presentation import com.intellij.openapi.actionSystem.impl.ActionButton import com.intellij.openapi.editor.event.EditorFactoryEvent import com.intellij.openapi.editor.event.EditorFactoryListener +import com.intellij.openapi.editor.ex.EditorMarkupModel import com.intellij.openapi.editor.impl.EditorImpl import com.intellij.openapi.editor.impl.EditorInspectionsActionToolbar import com.intellij.openapi.editor.impl.EditorMarkupModelImpl @@ -32,6 +33,22 @@ private class DecompilerInEditorListener : EditorFactoryListener { setupModeToggles(editor) } + /** + * This is a hack. See IDEA-368466. + * + * We want to add an icon to the small toolbar in the upper-right corner of the editor (aka "the inspection widget"). + * + * Normal, well-behaved plugins (for example GitHub plugin, for code review), contribute their own actions to the + * inspection widget by calling [EditorMarkupModel.addInspectionWidgetAction]. + * + * Unfortunately, we cannot act like a well-behaved plugin because the inspection widget is not shown for + * class files (and other binary artifacts). This assumption is hardcoded quite deep in platform code. + * + * Therefore, we replace the whole "status component" (which itself is a part of [JBScrollPane]). + * + * We assume we will not overwrite any existing UI that was already there – because there wasn't any UI to be + * overwritten – recall that the whole "status component" is not displayed for class files (and other binary artifacts). + */ private fun setupModeToggles(editor: EditorImpl) { val decompilerSettings = IdeaDecompilerSettings.getInstance()