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()