diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowPanel.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowPanel.kt index 3a340bde4386..0553763b9849 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowPanel.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/BytecodeToolWindowPanel.kt @@ -161,7 +161,7 @@ internal class BytecodeToolWindowPanel( return } - val linesRange = mapLines(bytecodeWithDebugInfo, sourceStartLine, sourceEndLine, true) + val linesRange = mapLines(bytecodeWithDebugInfo, sourceStartLine, sourceEndLine, showDebugInfo = false) if (linesRange == IntRange(0, 0) || linesRange.first < 0 || linesRange.last < 0) { bytecodeEditor.getSelectionModel().removeSelection() diff --git a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/bytecodeLineMapping.kt b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/bytecodeLineMapping.kt index 52f7bb18ccd9..cec5570a6645 100644 --- a/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/bytecodeLineMapping.kt +++ b/plugins/ByteCodeViewer/src/com/intellij/byteCodeViewer/bytecodeLineMapping.kt @@ -33,7 +33,7 @@ internal fun removeDebugInfo(bytecodeWithDebugInfo: String): String = bytecodeWi * @return A pair where the first element is the start line number in the bytecode, and the second element is the end line number in the bytecode. Returns (0, 0) if no valid mapping * is found. */ -internal fun mapLines(bytecodeWithDebugInfo: String, sourceStartLine: Int, sourceEndLine: Int, stripDebugInfo: Boolean = false): IntRange { +internal fun mapLines(bytecodeWithDebugInfo: String, sourceStartLine: Int, sourceEndLine: Int, showDebugInfo: Boolean = true): IntRange { var sourceStartLine = sourceStartLine // + 1 // editor selection is 0-indexed var currentBytecodeLine = 0 var bytecodeStartLine = -1 @@ -90,7 +90,7 @@ internal fun mapLines(bytecodeWithDebugInfo: String, sourceStartLine: Int, sourc currentBytecodeLine++ } - if (stripDebugInfo) { + if (!showDebugInfo) { bytecodeStartLine -= linesToSkipBeforeStartLine bytecodeEndLine -= linesToSkipBeforeEndLine } diff --git a/plugins/ByteCodeViewer/test/com/intellij/byteCodeViewer/BytecodeLineMappingTest.kt b/plugins/ByteCodeViewer/test/com/intellij/byteCodeViewer/BytecodeLineMappingTest.kt index ff394b7307e7..7b992457cd76 100644 --- a/plugins/ByteCodeViewer/test/com/intellij/byteCodeViewer/BytecodeLineMappingTest.kt +++ b/plugins/ByteCodeViewer/test/com/intellij/byteCodeViewer/BytecodeLineMappingTest.kt @@ -21,7 +21,7 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { bytecodeWithDebugInfo: String, bytecodeWithoutDebugInfo: String, expectedBytecodeSelection: String, - stripDebugInfo: Boolean = false, + showDebugInfo: Boolean = true, ) { val (startLine, endLine) = bootstrapAndGetSelection(source) @@ -29,14 +29,14 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { bytecodeWithDebugInfo = bytecodeWithDebugInfo, sourceStartLine = startLine, sourceEndLine = endLine, - stripDebugInfo = stripDebugInfo, + showDebugInfo = showDebugInfo, ) val bytecodeSelectionStart = linesRange.first var bytecodeSelectionEnd = linesRange.last bytecodeSelectionEnd++ // because most substring() functions use exclusive indexing for "end" bytecodeSelectionEnd++ // because string operations are 0-indexed but the editor is 1-indexed - assertEquals(expectedBytecodeSelection, (if (stripDebugInfo) bytecodeWithoutDebugInfo else bytecodeWithDebugInfo).lines().subList(bytecodeSelectionStart, bytecodeSelectionEnd).joinToString("\n")) + assertEquals(expectedBytecodeSelection, (if (showDebugInfo) bytecodeWithDebugInfo else bytecodeWithoutDebugInfo).lines().subList(bytecodeSelectionStart, bytecodeSelectionEnd).joinToString("\n")) } fun `test removeDebugInfo`() { @@ -265,7 +265,7 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { """.trimMargin("|")) } - fun `test (strip debug info) simple 1 method body - single line selected`() { + fun `test (no show debug info) simple 1 method body - single line selected`() { val source = """ package simple1; @@ -282,10 +282,10 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { | LDC "hello world" | INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | L1 - """.trimMargin("|"), stripDebugInfo = true) + """.trimMargin("|"), showDebugInfo = false) } - fun `test (strip debug info) simple 1 method body - from brace to brace`() { + fun `test (no show debug info) simple 1 method body - from brace to brace`() { val source = """ package simple1; @@ -304,10 +304,10 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { | L1 | RETURN | L2 - """.trimMargin("|"), stripDebugInfo = true) + """.trimMargin("|"), showDebugInfo = false) } - fun `test (strip debug info) simple 4 - works fine in presence of jumps (1)`() { + fun `test (no show debug info) simple 4 - works fine in presence of jumps (1)`() { val source = """ package simple4; @@ -356,10 +356,10 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { | LDC "bar" | ARETURN | L1 - """.trimMargin("|"), stripDebugInfo = true) + """.trimMargin("|"), showDebugInfo = false) } - fun `test (strip debug info) simple 4 - works fine in presence of jumps (2)`() { + fun `test (no show debug info) simple 4 - works fine in presence of jumps (2)`() { val source = """ package simple4; @@ -410,7 +410,7 @@ class BytecodeLineMappingTest : BasePlatformTestCase() { | LDC "foo" | ARETURN | L1 - """.trimMargin("|"), stripDebugInfo = true) + """.trimMargin("|"), showDebugInfo = false) } /**