Skip to content

Commit b9b6730

Browse files
cushongoogle-java-format Team
authored and
google-java-format Team
committed
Handle classes with no members and semi-colons
PiperOrigin-RevId: 638312117
1 parent bec248b commit b9b6730

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,12 @@ protected void addBodyDeclarations(
37443744
tokenBreakTrailingComment("{", plusTwo);
37453745
builder.blankLineWanted(BlankLineWanted.NO);
37463746
builder.open(ZERO);
3747+
if (builder.peekToken().equals(Optional.of(";"))) {
3748+
builder.open(plusTwo);
3749+
dropEmptyDeclarations();
3750+
builder.close();
3751+
builder.forcedBreak();
3752+
}
37473753
token("}", plusTwo);
37483754
builder.close();
37493755
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class SemicolonInClass {
2+
;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class SemicolonInClass {
2+
;
3+
}

0 commit comments

Comments
 (0)