From a42b2c1df1eea08d575ea164df378253e31c9723 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Sat, 5 Jul 2025 22:09:32 +0200 Subject: [PATCH] [ByteCodeViewer] reformat and optimize imports GitOrigin-RevId: aff3cbd742fae99cb127a607125efb96d00d4769 --- .../byteCodeViewer/ByteCodeViewerManager.kt | 14 ++++++++------ .../intellij/byteCodeViewer/ShowBytecodeAction.kt | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt index 273766dcff33..5229d4fde589 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ByteCodeViewerManager.kt @@ -9,7 +9,10 @@ import com.intellij.openapi.roots.ProjectFileIndex import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.vfs.VirtualFile import com.intellij.openapi.vfs.resolveFromRootOrRelative -import com.intellij.psi.* +import com.intellij.psi.PsiClass +import com.intellij.psi.PsiClassOwner +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiTypeParameter import com.intellij.psi.util.ClassUtil import com.intellij.psi.util.PsiTreeUtil import com.intellij.psi.util.PsiUtil @@ -37,15 +40,14 @@ object ByteCodeViewerManager { else { // source code; looking for a .class file in compiler output val moduleExtension = CompilerModuleExtension.getInstance(fileIndex.getModuleForFile(file)) ?: return null - val classRoot = if (fileIndex.isInTestSourceContent(file)) { - moduleExtension.compilerOutputPathForTests - } else { - moduleExtension.compilerOutputPath - } ?: return null + val classRoot = if (fileIndex.isInTestSourceContent(file)) moduleExtension.compilerOutputPathForTests + else moduleExtension.compilerOutputPath + if (classRoot == null) return null return classRoot.resolveFromRootOrRelative(jvmClassName.replace('.', '/') + ".class") } } + @Deprecated(message = "Use findClassFile instead") @JvmStatic fun loadClassFileBytes(aClass: PsiClass): ByteArray? { return findClassFile(aClass)?.contentsToByteArray(false) diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt index 78cc7a0c2d17..2479e2025f14 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/ShowBytecodeAction.kt @@ -109,7 +109,7 @@ internal class ShowBytecodeAction : AnAction() { } } } - + val syncWithEditorAction = object : ToggleAction(BytecodeViewerBundle.messagePointer("action.sync.with.editor.name")) { override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.EDT @@ -121,7 +121,7 @@ internal class ShowBytecodeAction : AnAction() { BytecodeViewerSettings.getInstance().state.syncWithEditor = state } } - + return DefaultActionGroup(showDebugAction, syncWithEditorAction) } }