mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-decompiler] off-by-one in line mapping (EA-75719)
This commit is contained in:
@@ -230,7 +230,7 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
|
||||
private class ExactMatchLineNumbersMapping(private val mapping: IntArray) : LineNumbersMapping {
|
||||
override fun bytecodeToSource(line: Int): Int {
|
||||
for (i in 0..mapping.size step 2) {
|
||||
for (i in mapping.indices step 2) {
|
||||
if (mapping[i] == line) {
|
||||
return mapping[i + 1]
|
||||
}
|
||||
@@ -239,7 +239,7 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
}
|
||||
|
||||
override fun sourceToBytecode(line: Int): Int {
|
||||
for (i in 0..mapping.size step 2) {
|
||||
for (i in mapping.indices step 2) {
|
||||
if (mapping[i + 1] == line) {
|
||||
return mapping[i]
|
||||
}
|
||||
|
||||
+4
@@ -104,7 +104,11 @@ class IdeaDecompilerTest : LightCodeInsightFixtureTestCase() {
|
||||
|
||||
val mapping = file.getUserData(LineNumbersMapping.LINE_NUMBERS_MAPPING_KEY)!!
|
||||
assertEquals(11, mapping.bytecodeToSource(3))
|
||||
assertEquals(3, mapping.sourceToBytecode(11))
|
||||
assertEquals(23, mapping.bytecodeToSource(13))
|
||||
assertEquals(13, mapping.sourceToBytecode(23))
|
||||
assertEquals(-1, mapping.bytecodeToSource(1000))
|
||||
assertEquals(-1, mapping.sourceToBytecode(1000))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user