diff --git a/src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java b/src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java index ad61f92..ce328a9 100644 --- a/src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java +++ b/src/org/jetbrains/java/decompiler/main/collectors/BytecodeSourceMapper.java @@ -29,7 +29,7 @@ public class BytecodeSourceMapper { private final Map>> mapping = new LinkedHashMap>>(); // original line to decompiled line - private final Map linesMapping = new LinkedHashMap(); + private final Map linesMapping = new HashMap(); public void addMapping(String className, String methodName, int bytecodeOffset, int sourceLine) { Map> class_mapping = mapping.get(className); @@ -56,6 +56,10 @@ public class BytecodeSourceMapper { } public void dumpMapping(TextBuffer buffer, boolean offsetsToHex) { + if (mapping.isEmpty() && linesMapping.isEmpty()) { + return; + } + String lineSeparator = DecompilerContext.getNewLineSeparator(); for (Entry>> class_entry : mapping.entrySet()) { @@ -91,9 +95,9 @@ public class BytecodeSourceMapper { // lines mapping buffer.append("Lines mapping:").appendLineSeparator(); - int[] mapping = getOriginalLinesMapping(); - for (int i = 0; i < mapping.length; i += 2) { - buffer.append(mapping[i]).append(" <-> ").append(mapping[i + 1]).appendLineSeparator(); + Map sorted = new TreeMap(linesMapping); + for (Entry entry : sorted.entrySet()) { + buffer.append(entry.getKey()).append(" <-> ").append(entry.getValue()).appendLineSeparator(); } } diff --git a/testData/results/TestClassSimpleBytecodeMapping.dec b/testData/results/TestClassSimpleBytecodeMapping.dec index 9dd881c..e5dfb1c 100644 --- a/testData/results/TestClassSimpleBytecodeMapping.dec +++ b/testData/results/TestClassSimpleBytecodeMapping.dec @@ -58,12 +58,12 @@ class 'pkg/TestClassSimpleBytecodeMapping' { } Lines mapping: -17 <-> 8 -21 <-> 11 -22 <-> 12 -23 <-> 13 -25 <-> 15 -26 <-> 16 -12 <-> 5 -14 <-> 6 -31 <-> 21 +12 <-> 2 +14 <-> 3 +17 <-> 5 +21 <-> 8 +22 <-> 9 +23 <-> 10 +25 <-> 12 +26 <-> 13 +31 <-> 18