From bb3ed0c94bcde79f6705eb481fb023720904a505 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 3 Nov 2025 11:33:07 +0100 Subject: [PATCH] [java-decompiler] IDEA-381628 fix PIEAE in ShowDecompiledClassAction#update() PIEAE: PsiInvalidElementAccessException GitOrigin-RevId: 359b1fc4c78c6ab41d8a09a150cae71cc4e84ec1 --- .../java/decompiler/ShowDecompiledClassAction.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 000bb7ac6c28..dc5b2ac5db56 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 @@ -38,8 +38,15 @@ class ShowDecompiledClassAction : AnAction() { private fun getPsiElement(e: AnActionEvent): PsiElement? { val project = e.project ?: return null - val editor = e.getData(CommonDataKeys.EDITOR) ?: return e.getData(CommonDataKeys.PSI_ELEMENT) - return PsiUtilBase.getPsiFileInEditor(editor, project)?.findElementAt(editor.caretModel.offset) + val editor = e.getData(CommonDataKeys.EDITOR) + val element = if (editor != null) { + PsiUtilBase.getPsiFileInEditor(editor, project)?.findElementAt(editor.caretModel.offset) + } + else { + e.getData(CommonDataKeys.PSI_ELEMENT) + } + if (element == null || !element.isValid) return null + return element } private fun getOriginalFile(psiElement: PsiElement?): VirtualFile? {