File tree Expand file tree Collapse file tree 3 files changed +46
-4
lines changed
main/java/com/google/googlejavaformat/java
test/resources/com/google/googlejavaformat/java/testdata Expand file tree Collapse file tree 3 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -834,10 +834,24 @@ public boolean visitEnumDeclaration(ClassTree node) {
834834 members .add (member );
835835 }
836836 if (enumConstants .isEmpty () && members .isEmpty ()) {
837- builder .open (ZERO );
838- builder .blankLineWanted (BlankLineWanted .NO );
839- token ("}" );
840- builder .close ();
837+ if (builder .peekToken ().equals (Optional .of (";" ))) {
838+ builder .open (plusTwo );
839+ builder .forcedBreak ();
840+ token (";" );
841+ builder .forcedBreak ();
842+ dropEmptyDeclarations ();
843+ builder .close ();
844+ builder .open (ZERO );
845+ builder .forcedBreak ();
846+ builder .blankLineWanted (BlankLineWanted .NO );
847+ token ("}" , plusTwo );
848+ builder .close ();
849+ } else {
850+ builder .open (ZERO );
851+ builder .blankLineWanted (BlankLineWanted .NO );
852+ token ("}" );
853+ builder .close ();
854+ }
841855 } else {
842856 builder .open (plusTwo );
843857 builder .blankLineWanted (BlankLineWanted .NO );
Original file line number Diff line number Diff line change 1+ public enum Empty {}
2+ public enum Empty {;}
3+ public enum Empty {;;;}
4+ public enum Empty {; // comment
5+ ;;}
6+ public enum Empty {;
7+ ;; // comment
8+ }
Original file line number Diff line number Diff line change 1+ public enum Empty {}
2+
3+ public enum Empty {
4+ ;
5+ }
6+
7+ public enum Empty {
8+ ;
9+ ;;
10+ }
11+
12+ public enum Empty {
13+ ; // comment
14+ ;;
15+ }
16+
17+ public enum Empty {
18+ ;
19+ ;; // comment
20+ }
You can’t perform that action at this time.
0 commit comments