mirror of
https://github.com/moparisthebest/fernflower
synced 2025-02-16 15:00:16 -05:00
java-decompiler: test fix
This commit is contained in:
parent
3199686543
commit
ce721c7acd
@ -29,7 +29,7 @@ public class BytecodeSourceMapper {
|
|||||||
private final Map<String, Map<String, Map<Integer, Integer>>> mapping = new LinkedHashMap<String, Map<String, Map<Integer, Integer>>>();
|
private final Map<String, Map<String, Map<Integer, Integer>>> mapping = new LinkedHashMap<String, Map<String, Map<Integer, Integer>>>();
|
||||||
|
|
||||||
// original line to decompiled line
|
// original line to decompiled line
|
||||||
private final Map<Integer, Integer> linesMapping = new LinkedHashMap<Integer, Integer>();
|
private final Map<Integer, Integer> linesMapping = new HashMap<Integer, Integer>();
|
||||||
|
|
||||||
public void addMapping(String className, String methodName, int bytecodeOffset, int sourceLine) {
|
public void addMapping(String className, String methodName, int bytecodeOffset, int sourceLine) {
|
||||||
Map<String, Map<Integer, Integer>> class_mapping = mapping.get(className);
|
Map<String, Map<Integer, Integer>> class_mapping = mapping.get(className);
|
||||||
@ -56,6 +56,10 @@ public class BytecodeSourceMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void dumpMapping(TextBuffer buffer, boolean offsetsToHex) {
|
public void dumpMapping(TextBuffer buffer, boolean offsetsToHex) {
|
||||||
|
if (mapping.isEmpty() && linesMapping.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
String lineSeparator = DecompilerContext.getNewLineSeparator();
|
||||||
|
|
||||||
for (Entry<String, Map<String, Map<Integer, Integer>>> class_entry : mapping.entrySet()) {
|
for (Entry<String, Map<String, Map<Integer, Integer>>> class_entry : mapping.entrySet()) {
|
||||||
@ -91,9 +95,9 @@ public class BytecodeSourceMapper {
|
|||||||
|
|
||||||
// lines mapping
|
// lines mapping
|
||||||
buffer.append("Lines mapping:").appendLineSeparator();
|
buffer.append("Lines mapping:").appendLineSeparator();
|
||||||
int[] mapping = getOriginalLinesMapping();
|
Map<Integer, Integer> sorted = new TreeMap<Integer, Integer>(linesMapping);
|
||||||
for (int i = 0; i < mapping.length; i += 2) {
|
for (Entry<Integer, Integer> entry : sorted.entrySet()) {
|
||||||
buffer.append(mapping[i]).append(" <-> ").append(mapping[i + 1]).appendLineSeparator();
|
buffer.append(entry.getKey()).append(" <-> ").append(entry.getValue()).appendLineSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ class 'pkg/TestClassSimpleBytecodeMapping' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Lines mapping:
|
Lines mapping:
|
||||||
17 <-> 8
|
12 <-> 2
|
||||||
21 <-> 11
|
14 <-> 3
|
||||||
22 <-> 12
|
17 <-> 5
|
||||||
23 <-> 13
|
21 <-> 8
|
||||||
25 <-> 15
|
22 <-> 9
|
||||||
26 <-> 16
|
23 <-> 10
|
||||||
12 <-> 5
|
25 <-> 12
|
||||||
14 <-> 6
|
26 <-> 13
|
||||||
31 <-> 21
|
31 <-> 18
|
||||||
|
Loading…
Reference in New Issue
Block a user