fixed line numbers in case of decompile error

master
Egor Ushakov 7 years ago
parent c241278aee
commit 97ff04b51c
  1. 10
      src/org/jetbrains/java/decompiler/main/ClassWriter.java

@ -827,11 +827,16 @@ public class ClassWriter {
if (root != null && !methodWrapper.decompiledWithErrors) { // check for existence if (root != null && !methodWrapper.decompiledWithErrors) { // check for existence
try { try {
TextBuffer code = root.toJava(indent + 1, tracer); // to restore in case of an exception
BytecodeMappingTracer codeTracer = new BytecodeMappingTracer(tracer.getCurrentSourceLine());
TextBuffer code = root.toJava(indent + 1, codeTracer);
hideMethod = (clinit || dinit || hideConstructor(wrapper, init, throwsExceptions, paramCount)) && code.length() == 0; hideMethod = (clinit || dinit || hideConstructor(wrapper, init, throwsExceptions, paramCount)) && code.length() == 0;
buffer.append(code); buffer.append(code);
tracer.setCurrentSourceLine(codeTracer.getCurrentSourceLine());
tracer.addTracer(codeTracer);
} }
catch (Throwable ex) { catch (Throwable ex) {
DecompilerContext.getLogger() DecompilerContext.getLogger()
@ -848,8 +853,7 @@ public class ClassWriter {
buffer.appendLineSeparator(); buffer.appendLineSeparator();
tracer.incrementCurrentSourceLine(); tracer.incrementCurrentSourceLine();
} }
else if (root != null) {
if (root != null) {
tracer.addMapping(root.getDummyExit().bytecode); tracer.addMapping(root.getDummyExit().bytecode);
} }
buffer.appendIndent(indent).append('}').appendLineSeparator(); buffer.appendIndent(indent).append('}').appendLineSeparator();

Loading…
Cancel
Save