fix extra semicolon in decompiled empty blocks IDEA-196314 #843

This commit is contained in:
temp1011
2018-07-31 13:26:13 +03:00
committed by Egor Ushakov
parent 8824c20cbb
commit 02fdbec132
13 changed files with 160 additions and 75 deletions

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.modules.decompiler.stats;
import org.jetbrains.java.decompiler.code.CodeConstants;
@@ -171,7 +169,7 @@ public class CatchStatement extends Statement {
buf.append(vars.get(i - 1).toJava(indent, tracer));
buf.append(") {").appendLineSeparator();
tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(stat, indent + 1, true, tracer)).appendIndent(indent)
buf.append(ExprProcessor.jmpWrapper(stat, indent + 1, false, tracer)).appendIndent(indent)
.append("}");
}
buf.appendLineSeparator();

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.modules.decompiler.stats;
import org.jetbrains.java.decompiler.util.TextBuffer;
@@ -93,21 +91,21 @@ public class DoStatement extends Statement {
case LOOP_DO:
buf.appendIndent(indent).append("while(true) {").appendLineSeparator();
tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, false, tracer));
buf.appendIndent(indent).append("}").appendLineSeparator();
tracer.incrementCurrentSourceLine();
break;
case LOOP_DOWHILE:
buf.appendIndent(indent).append("do {").appendLineSeparator();
tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, false, tracer));
buf.appendIndent(indent).append("} while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(");").appendLineSeparator();
tracer.incrementCurrentSourceLine();
break;
case LOOP_WHILE:
buf.appendIndent(indent).append("while(").append(conditionExprent.get(0).toJava(indent, tracer)).append(") {").appendLineSeparator();
tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, false, tracer));
buf.appendIndent(indent).append("}").appendLineSeparator();
tracer.incrementCurrentSourceLine();
break;
@@ -120,7 +118,7 @@ public class DoStatement extends Statement {
.append(conditionExprent.get(0).toJava(indent, tracer)).append("; ").append(incExprent.get(0).toJava(indent, tracer)).append(") {")
.appendLineSeparator();
tracer.incrementCurrentSourceLine();
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, true, tracer));
buf.append(ExprProcessor.jmpWrapper(first, indent + 1, false, tracer));
buf.appendIndent(indent).append("}").appendLineSeparator();
tracer.incrementCurrentSourceLine();
}

View File

@@ -1,6 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.java.decompiler.modules.decompiler.stats;
import org.jetbrains.java.decompiler.util.TextBuffer;
@@ -204,24 +202,26 @@ public class IfStatement extends Statement {
tracer.incrementCurrentSourceLine();
if (ifstat == null) {
buf.appendIndent(indent + 1);
boolean semicolon = false;
if (ifedge.explicit) {
semicolon = true;
if (ifedge.getType() == StatEdge.TYPE_BREAK) {
// break
buf.append("break");
buf.appendIndent(indent + 1).append("break");
}
else {
// continue
buf.append("continue");
buf.appendIndent(indent + 1).append("continue");
}
if (ifedge.labeled) {
buf.append(" label").append(ifedge.closure.id.toString());
}
}
buf.append(";").appendLineSeparator();
tracer.incrementCurrentSourceLine();
if(semicolon) {
buf.append(";").appendLineSeparator();
tracer.incrementCurrentSourceLine();
}
}
else {
buf.append(ExprProcessor.jmpWrapper(ifstat, indent + 1, true, tracer));