Skip to content

Commit a7bbb1f

Browse files
Fix odd indenting of "else" in generated Java code (#810)
Previously, normal if/else statements would be formatted like: if.. { } else { } and if/else blocks with an empty if block would be formatted like: if... {} else { } Made all if/else statments be formatted like if { } else { } Co-authored-by: Ankush Desai <[email protected]>
1 parent 49055ad commit a7bbb1f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Src/PCompiler/CompilerCore/Backend/Java/MachineGenerator.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ private void WriteStmt(IPStmt stmt)
445445

446446
if (ifStmt.ThenBranch.Statements.Count == 0)
447447
{
448-
Write("{}");
448+
WriteLine("{");
449+
WriteLine("}");
449450
}
450451
else
451452
{
@@ -454,7 +455,7 @@ private void WriteStmt(IPStmt stmt)
454455

455456
if (ifStmt.ElseBranch != null && ifStmt.ElseBranch.Statements.Count > 0)
456457
{
457-
WriteLine(" else ");
458+
WriteLine("else");
458459
WriteStmt(ifStmt.ElseBranch);
459460
}
460461
break;
@@ -964,4 +965,4 @@ private void WriteStructureAccess(IPExpr e)
964965
}
965966

966967
}
967-
}
968+
}

0 commit comments

Comments
 (0)