File tree Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Expand file tree Collapse file tree 2 files changed +4
-9
lines changed Original file line number Diff line number Diff line change @@ -60,15 +60,16 @@ fn main() -> Result<(), String> {
6060 } ;
6161
6262 let formatter = Formatter :: new ( & allocator, options) ;
63+ let formatted = formatter. format ( & ret. program ) ;
6364 if show_ir {
64- let doc = formatter . doc ( & ret . program ) ;
65+ // Do not rely on `Display` of `Document` here, as it shows Prettier IR
6566 println ! ( "[" ) ;
66- for el in doc . iter ( ) {
67+ for el in formatted . document ( ) . iter ( ) {
6768 println ! ( " {el:?}," ) ;
6869 }
6970 println ! ( "]" ) ;
7071 } else {
71- let code = formatter . build ( & ret . program ) ;
72+ let code = formatted . print ( ) . map_err ( |e| e . to_string ( ) ) ? . into_code ( ) ;
7273 println ! ( "{code}" ) ;
7374 }
7475
Original file line number Diff line number Diff line change @@ -55,12 +55,6 @@ impl<'a> Formatter<'a> {
5555 Self { allocator, source_text : "" , options }
5656 }
5757
58- /// Formats the given AST `Program` and returns the IR before printing.
59- pub fn doc ( mut self , program : & ' a Program < ' a > ) -> Document < ' a > {
60- let formatted = self . format ( program) ;
61- formatted. into_document ( )
62- }
63-
6458 /// Formats the given AST `Program` and returns the formatted string.
6559 pub fn build ( mut self , program : & Program < ' a > ) -> String {
6660 let formatted = self . format ( program) ;
You can’t perform that action at this time.
0 commit comments