diff --git a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java index e10368f63..58995e03c 100644 --- a/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java +++ b/core/src/main/java/com/google/googlejavaformat/java/JavaInputAstVisitor.java @@ -2403,13 +2403,16 @@ public Void visitProvides(ProvidesTree node, Void unused) { public Void visitRequires(RequiresTree node, Void unused) { token("requires"); builder.space(); - if (builder.peekToken().equals(Optional.of("static"))) { - token("static"); - builder.space(); - } - if (builder.peekToken().equals(Optional.of("transitive"))) { - token("transitive"); - builder.space(); + while (true) { + if (builder.peekToken().equals(Optional.of("static"))) { + token("static"); + builder.space(); + } else if (builder.peekToken().equals(Optional.of("transitive"))) { + token("transitive"); + builder.space(); + } else { + break; + } } scan(node.getModuleName(), null); token(";"); diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.input b/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.input new file mode 100644 index 000000000..c5d29662f --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.input @@ -0,0 +1,6 @@ +@Deprecated +module moduletags { + requires transitive static moduleA; + + exports testpkgmdltags; +} \ No newline at end of file diff --git a/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.output b/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.output new file mode 100644 index 000000000..563ef46f2 --- /dev/null +++ b/core/src/test/resources/com/google/googlejavaformat/java/testdata/M3.output @@ -0,0 +1,6 @@ +@Deprecated +module moduletags { + requires transitive static moduleA; + + exports testpkgmdltags; +}