From 7fd83bae3f0d2bb4ff805ad9e93fe930667faf0e Mon Sep 17 00:00:00 2001 From: Jordan Kiesel Date: Sun, 15 Nov 2026 14:33:42 -0700 Subject: [PATCH] fix: break annotations on module declarations --- src/printers/packages-and-modules.ts | 14 ++++++++------ test/unit-test/modules/_input.java | 13 +++++++++++-- test/unit-test/modules/_output.java | 10 ++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/printers/packages-and-modules.ts b/src/printers/packages-and-modules.ts index c34626d4..e4431d03 100644 --- a/src/printers/packages-and-modules.ts +++ b/src/printers/packages-and-modules.ts @@ -122,21 +122,23 @@ export default { child.node.type === SyntaxType.Annotation || child.node.type === SyntaxType.MarkerAnnotation ) { - parts.push(print(child)); + parts.push(print(child), hardline); } }, "namedChildren"); if (path.node.children.some(({ type }) => type === "open")) { - parts.push("open"); + parts.push("open", " "); } parts.push( - "module", - path.call(print, "nameNode"), - path.call(print, "bodyNode") + join(" ", [ + "module", + path.call(print, "nameNode"), + path.call(print, "bodyNode") + ]) ); - return join(" ", parts); + return parts; }, module_body(path, print) { diff --git a/test/unit-test/modules/_input.java b/test/unit-test/modules/_input.java index 06799605..743fa793 100644 --- a/test/unit-test/modules/_input.java +++ b/test/unit-test/modules/_input.java @@ -26,5 +26,14 @@ provides fr.soat.vending.machine.model.it.should.be.breaking.but.only.a.part with another , again,ano ; provides model with another , again,ano,another , again,ano,another , again,ano,another , again,averyveryveryveryveryveryveryveryveryveryverylongname ; - -} \ No newline at end of file + +} + +@Annotation module m { + requires a; +} + +@SuppressWarnings("x") // note +module m { + requires a; +} diff --git a/test/unit-test/modules/_output.java b/test/unit-test/modules/_output.java index 2d31d77b..ab93e701 100644 --- a/test/unit-test/modules/_output.java +++ b/test/unit-test/modules/_output.java @@ -63,3 +63,13 @@ again, averyveryveryveryveryveryveryveryveryveryverylongname; } + +@Annotation +module m { + requires a; +} + +@SuppressWarnings("x") // note +module m { + requires a; +}