@@ -637,16 +637,26 @@ const shared = {
637
637
* @param {State } state
638
638
*/
639
639
'BlockStatement|ClassBody' : ( node , state ) => {
640
- if ( node . body . length === 0 ) {
641
- state . commands . push ( '{}' ) ;
642
- return ;
640
+ if ( node . loc ) {
641
+ const { line, column } = node . loc . start ;
642
+ state . commands . push ( l ( line , column ) , '{' , l ( line , column + 1 ) ) ;
643
+ } else {
644
+ state . commands . push ( '{' ) ;
643
645
}
644
646
645
- state . multiline = true ;
647
+ if ( node . body . length > 0 ) {
648
+ state . multiline = true ;
649
+ state . commands . push ( indent , newline ) ;
650
+ handle_body ( node . body , state ) ;
651
+ state . commands . push ( dedent , newline ) ;
652
+ }
646
653
647
- state . commands . push ( '{' , indent , newline ) ;
648
- handle_body ( node . body , state ) ;
649
- state . commands . push ( dedent , newline , '}' ) ;
654
+ if ( node . loc ) {
655
+ const { line, column } = node . loc . end ;
656
+ state . commands . push ( l ( line , column - 1 ) , '}' , l ( line , column ) ) ;
657
+ } else {
658
+ state . commands . push ( '}' ) ;
659
+ }
650
660
} ,
651
661
652
662
/**
0 commit comments