[java decompiler] adds an empty line before local classes

master
Roman Shevchenko 7 years ago
parent a3332a5f31
commit 45486cd4d4
  1. 1
      src/org/jetbrains/java/decompiler/main/TextBuffer.java
  2. 10
      src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
  3. 49
      testData/results/TestLocalClass.dec

@ -10,6 +10,7 @@ import java.util.*;
*
* @author egor
*/
@SuppressWarnings("UnusedReturnValue")
public class TextBuffer {
private final String myLineSeparator = DecompilerContext.getNewLineSeparator();
private final String myIndent = (String)DecompilerContext.getProperty(IFernflowerPreferences.INDENT_STRING);

@ -731,8 +731,7 @@ public class ExprProcessor implements CodeConstants {
return !(type == Exprent.EXPRENT_SWITCH ||
type == Exprent.EXPRENT_MONITOR ||
type == Exprent.EXPRENT_IF ||
(type == Exprent.EXPRENT_VAR && ((VarExprent)expr)
.isClassDef()));
(type == Exprent.EXPRENT_VAR && ((VarExprent)expr).isClassDef()));
}
private static void addDeletedGotoInstructionMapping(Statement stat, BytecodeMappingTracer tracer) {
@ -803,7 +802,14 @@ public class ExprProcessor implements CodeConstants {
TextBuffer buf = new TextBuffer();
for (Exprent expr : lst) {
if (buf.length() > 0 && expr.type == Exprent.EXPRENT_VAR && ((VarExprent)expr).isClassDef()) {
// separates local class definition from previous statements
buf.appendLineSeparator();
tracer.incrementCurrentSourceLine();
}
TextBuffer content = expr.toJava(indent, tracer);
if (content.length() > 0) {
if (expr.type != Exprent.EXPRENT_VAR || !((VarExprent)expr).isClassDef()) {
buf.appendIndent(indent);

@ -3,6 +3,7 @@ package pkg;
public abstract class TestLocalClass {
void foo() {
boolean var1 = true;// 8
class Local {
void foo() {
boolean var1 = true;// 11
@ -25,11 +26,11 @@ public abstract class TestLocalClass {
class 'pkg/TestLocalClass$1Local' {
method 'foo ()V' {
0 7
1 7
2 8
3 8
4 9
0 8
1 8
2 9
3 9
4 10
}
}
@ -37,33 +38,33 @@ class 'pkg/TestLocalClass' {
method 'foo ()V' {
0 4
1 4
a 12
c 13
f 14
a 13
c 14
f 15
}
method 'boo ()V' {
0 17
1 17
2 18
0 18
1 18
2 19
}
method 'zoo ()V' {
0 21
1 21
2 22
0 22
1 22
2 23
}
}
Lines mapping:
8 <-> 5
11 <-> 8
12 <-> 9
13 <-> 10
15 <-> 13
16 <-> 14
17 <-> 15
20 <-> 18
21 <-> 19
24 <-> 22
25 <-> 23
11 <-> 9
12 <-> 10
13 <-> 11
15 <-> 14
16 <-> 15
17 <-> 16
20 <-> 19
21 <-> 20
24 <-> 23
25 <-> 24

Loading…
Cancel
Save