Fix minor autoformatter bugs. Fixes #4185.

Enums without semicolons and labels that aren't in a method body.
This commit is contained in:
George Bateman
2015-12-12 14:37:42 +00:00
parent 09ee576af5
commit cbf974630b

View File

@@ -587,6 +587,7 @@ public class AutoFormat implements Formatter {
break;
}
// In a simple enum, there's not necessarily a `;` to end the statement.
inStatementFlag = false;
curlyLvl--;
@@ -606,6 +607,7 @@ public class AutoFormat implements Formatter {
trimRight(result);
result.append('\n');
overflowFlag = false; // Would normally be done in writeIndentedLine.
printIndentation();
result.append(c);
if (peek() == ';') result.append(nextChar());
@@ -728,10 +730,14 @@ public class AutoFormat implements Formatter {
inStatementFlag = false;
arrayLevel = -1; // Unlikely to be needed; just in case.
//Same format for case, default, and other labels.
tabs--;
writeIndentedLine();
tabs++;
// Same format for case, default, and other labels.
if (tabs > 0) {
tabs--;
writeIndentedLine();
tabs++;
} else {
writeIndentedLine();
}
readForNewLine();
writeIndentedLine();