Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch formatting #52

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 ||
Expand Down