Skip to content

Commit 8177d5a

Browse files
committed
fix: prevent forced wrapping of annotated records
1 parent ad28ffa commit 8177d5a

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/printers/classes.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,8 @@ export default {
399399
},
400400

401401
record_declaration(path, print) {
402-
const parts = printModifiers(path, print, "declarationOnly");
403-
404-
parts.push("record ", path.call(print, "nameNode"));
402+
const modifiers = printModifiers(path, print, "declarationOnly");
403+
const parts = ["record ", path.call(print, "nameNode")];
405404

406405
if (hasChild(path, "type_parametersNode")) {
407406
parts.push(group(path.call(print, "type_parametersNode")));
@@ -426,7 +425,7 @@ export default {
426425
parts.push(" ");
427426
}
428427

429-
return [group(parts), path.call(print, "bodyNode")];
428+
return [...modifiers, group(parts), path.call(print, "bodyNode")];
430429
},
431430

432431
compact_constructor_declaration(path, print) {

test/unit-test/records/_input.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,9 @@ record Aaaaaaaaaa<Bbbbbbbbbb, Cccccccccc, Dddddddddd, Eeeeeeeeee, Ffffffffff, Gg
185185

186186
void a() {}
187187
}
188+
189+
@A
190+
record B(
191+
C c,
192+
D d
193+
) {}

test/unit-test/records/_output.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,3 +215,6 @@ record Aaaaaaaaaa<
215215
{
216216
void a() {}
217217
}
218+
219+
@A
220+
record B(C c, D d) {}

0 commit comments

Comments
 (0)