@@ -1199,31 +1199,16 @@ function printAttrs(path, options, print, { inline = false } = {}) {
11991199 if ( ! path . node . attrGroups ) {
12001200 return [ ] ;
12011201 }
1202- path . each ( ( ) => {
1203- const attrGroup = [ "#[" ] ;
1202+ path . each ( ( attrGroupPath ) => {
12041203 if ( ! inline && allAttrs . length > 0 ) {
12051204 allAttrs . push ( hardline ) ;
12061205 }
1207- attrGroup . push ( softline ) ;
1208- path . each ( ( ) => {
1209- const attrNode = path . node ;
1210- if ( attrGroup . length > 2 ) {
1211- attrGroup . push ( "," , line ) ;
1212- }
1213- const attrStmt = [ attrNode . name ] ;
1214- if ( attrNode . args . length > 0 ) {
1215- attrStmt . push ( printArgumentsList ( path , options , print , "args" ) ) ;
1216- }
1217- attrGroup . push ( group ( attrStmt ) ) ;
1218- } , "attrs" ) ;
12191206 allAttrs . push (
1220- group ( [
1221- indent ( attrGroup ) ,
1222- ifBreak ( shouldPrintComma ( options , 8.0 ) ? "," : "" ) ,
1223- softline ,
1224- "]" ,
1225- inline ? ifBreak ( softline , " " ) : "" ,
1226- ] )
1207+ printAllComments (
1208+ attrGroupPath ,
1209+ ( ) => printAttrGroup ( attrGroupPath , options , print , { inline } ) ,
1210+ options
1211+ )
12271212 ) ;
12281213 } , "attrGroups" ) ;
12291214 if ( allAttrs . length === 0 ) {
@@ -1232,6 +1217,29 @@ function printAttrs(path, options, print, { inline = false } = {}) {
12321217 return [ ...allAttrs , inline ? "" : hardline ] ;
12331218}
12341219
1220+ function printAttrGroup ( path , options , print , { inline = false } = { } ) {
1221+ const attrGroup = [ "#[" ] ;
1222+ attrGroup . push ( softline ) ;
1223+ path . each ( ( ) => {
1224+ const attrNode = path . node ;
1225+ if ( attrGroup . length > 2 ) {
1226+ attrGroup . push ( "," , line ) ;
1227+ }
1228+ const attrStmt = [ attrNode . name ] ;
1229+ if ( attrNode . args . length > 0 ) {
1230+ attrStmt . push ( printArgumentsList ( path , options , print , "args" ) ) ;
1231+ }
1232+ attrGroup . push ( group ( attrStmt ) ) ;
1233+ } , "attrs" ) ;
1234+ return group ( [
1235+ indent ( attrGroup ) ,
1236+ ifBreak ( shouldPrintComma ( options , 8.0 ) ? "," : "" ) ,
1237+ softline ,
1238+ "]" ,
1239+ inline ? ifBreak ( softline , " " ) : "" ,
1240+ ] ) ;
1241+ }
1242+
12351243function printClass ( path , options , print ) {
12361244 const { node } = path ;
12371245 const isAnonymousClass = node . kind === "class" && node . isAnonymous ;
@@ -2909,6 +2917,7 @@ function printNode(path, options, print) {
29092917
29102918 case "enumcase" :
29112919 return group ( [
2920+ ...printAttrs ( path , options , print ) ,
29122921 "case " ,
29132922 print ( "name" ) ,
29142923 node . value
0 commit comments