diff --git a/Procyon.CompilerTools/src/main/java/com/strobel/decompiler/languages/java/JavaOutputVisitor.java b/Procyon.CompilerTools/src/main/java/com/strobel/decompiler/languages/java/JavaOutputVisitor.java index 90cb2546..bc650909 100644 --- a/Procyon.CompilerTools/src/main/java/com/strobel/decompiler/languages/java/JavaOutputVisitor.java +++ b/Procyon.CompilerTools/src/main/java/com/strobel/decompiler/languages/java/JavaOutputVisitor.java @@ -19,7 +19,6 @@ import com.strobel.assembler.ir.attributes.AttributeNames; import com.strobel.assembler.ir.attributes.LineNumberTableAttribute; import com.strobel.assembler.ir.attributes.ModuleAttribute; -import com.strobel.assembler.ir.attributes.PermittedSubclassesAttribute; import com.strobel.assembler.ir.attributes.SourceAttribute; import com.strobel.assembler.metadata.*; import com.strobel.core.ArrayUtilities; @@ -959,7 +958,27 @@ else if (parent instanceof WhileStatement) { } if (!(parent instanceof Expression || parent instanceof DoWhileStatement)) { - newLine(); + if ((parent.getNextSibling() != null && parent.getNextSibling().getRole() == TryCatchStatement.FINALLY_BLOCK_ROLE) || (node.getRole() == TryCatchStatement.TRY_BLOCK_ROLE && node.getNextSibling().getRole() == TryCatchStatement.FINALLY_BLOCK_ROLE)) { + if (policy.PlaceFinallyOnNewLine) { + newLine(); + } else { + space(); + } + } else if (parent.getNextSibling() instanceof CatchClause || (parent instanceof TryCatchStatement && node.getNextSibling() instanceof CatchClause)) { + if (policy.PlaceCatchOnNewLine) { + newLine(); + } else { + space(); + } + } else if (parent instanceof IfElseStatement && node.getRole() == IfElseStatement.TRUE_ROLE && node != parent.getLastChild()) { + if (policy.PlaceElseOnNewLine) { + newLine(); + } else { + space(); + } + } else { + newLine(); + } } endNode(node); @@ -2695,7 +2714,7 @@ public Void visitArrayCreationExpression(final ArrayCreationExpression node, fin boolean needType = true; - //noinspection RedundantIfStatement + // noinspection RedundantIfStatement if (node.getDimensions().isEmpty() && node.getType() != null && (node.getParent() instanceof ArrayInitializerExpression ||