Skip to content

Commit 61c8c9b

Browse files
committed
Improve empty declaration handling
Ten empty declarations should be enough for anyone, but I forgot lookahead was supported when I did 8a25d00 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115090341
1 parent fdf1262 commit 61c8c9b

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,6 @@ private static final ImmutableList<Op> forceBreakList(Optional<BreakTag> breakTa
339339
private static final int MAX_FILLED_INFIX_LINES = 1;
340340
private static final int MAX_LINES_FOR_FORMAL_LIST = 1;
341341

342-
private static final int MAX_EMPTY_DECLS = 10;
343-
344342
/**
345343
* The {@code Visitor} constructor.
346344
* @param builder the {@link OpsBuilder}
@@ -412,10 +410,10 @@ public boolean visit(CompilationUnit node) {
412410
return false;
413411
}
414412

415-
/** Skips over extra semi-colon at the top-level, or in a class member declaration lists. */
413+
/** Skips over extra semi-colons at the top-level, or in a class member declaration lists. */
416414
private void dropEmptyDeclarations() {
417-
for (int times = 0; times < MAX_EMPTY_DECLS; times++) {
418-
builder.guessToken(";");
415+
while (builder.peekToken().equals(Optional.of(";"))) {
416+
token(";");
419417
}
420418
}
421419

0 commit comments

Comments
 (0)