decompiler: better line matching for single block methods

master
Egor.Ushakov 10 years ago
parent 500f8b12d8
commit 917c680276
  1. 6
      src/org/jetbrains/java/decompiler/main/collectors/BytecodeMappingTracer.java
  2. 6
      testData/results/InvalidMethodSignature.dec
  3. 12
      testData/results/TestEnum.dec

@ -101,6 +101,8 @@ public class BytecodeMappingTracer {
} }
Map<Integer, Integer> res = new HashMap<Integer, Integer>(); Map<Integer, Integer> res = new HashMap<Integer, Integer>();
// first match offsets from line number table
int[] data = lineNumberTable.getRawData(); int[] data = lineNumberTable.getRawData();
for (int i = 0; i < data.length; i += 2) { for (int i = 0; i < data.length; i += 2) {
int originalOffset = data[i]; int originalOffset = data[i];
@ -113,9 +115,11 @@ public class BytecodeMappingTracer {
unmappedLines.add(originalLine); unmappedLines.add(originalLine);
} }
} }
// now match offsets from decompiler mapping
for (Entry<Integer, Integer> entry : mapping.entrySet()) { for (Entry<Integer, Integer> entry : mapping.entrySet()) {
int originalLine = lineNumberTable.findLineNumber(entry.getKey()); int originalLine = lineNumberTable.findLineNumber(entry.getKey());
if (originalLine > -1) { if (originalLine > -1 && !res.containsKey(originalLine)) {
res.put(originalLine, entry.getValue()); res.put(originalLine, entry.getValue());
unmappedLines.remove(originalLine); unmappedLines.remove(originalLine);
} }

@ -12,9 +12,9 @@ class i implements bg {
private final b b; private final b b;
i(b var1, j var2) { i(b var1, j var2) {
this.b = var1; this.b = var1;// 1
this.a = var2; this.a = var2;
}// 1 }
public void a(c var1, k var2, boolean var3) { public void a(c var1, k var2, boolean var3) {
File var4 = this.a.b().a(var1);// 2 File var4 = this.a.b().a(var1);// 2
@ -50,7 +50,7 @@ class 'a/a/a/a/e/f/i' {
Lines mapping: Lines mapping:
0 <-> 25 0 <-> 25
1 <-> 17 1 <-> 15
2 <-> 20 2 <-> 20
3 <-> 21 3 <-> 21
4 <-> 22 4 <-> 22

@ -18,12 +18,12 @@ public enum TestEnum {
}// 30 }// 30
private TestEnum() { private TestEnum() {
this("?"); this("?");// 34
}// 34 }
private TestEnum(@Deprecated String var3) { private TestEnum(@Deprecated String var3) {
this.s = var3; this.s = var3;// 35
}// 35 }
} }
class 'pkg/TestEnum$1' { class 'pkg/TestEnum$1' {
@ -59,5 +59,5 @@ Lines mapping:
22 <-> 7 22 <-> 7
27 <-> 12 27 <-> 12
30 <-> 18 30 <-> 18
34 <-> 22 34 <-> 21
35 <-> 26 35 <-> 25

Loading…
Cancel
Save