@@ -2,17 +2,17 @@ use std::path::Path;
22use std:: sync:: Arc ;
33
44use anyhow:: Result ;
5- use deno_ast:: oxc:: allocator:: Allocator ;
65use deno_ast:: ParsedSource ;
6+ use deno_ast:: oxc:: allocator:: Allocator ;
77use dprint_core:: configuration:: resolve_new_line_kind;
88use dprint_core:: formatting:: * ;
99
10- use crate :: swc :: ensure_no_specific_syntax_errors;
10+ use crate :: parse :: ensure_no_specific_syntax_errors;
1111
1212use super :: configuration:: Configuration ;
13- use super :: generation:: generate;
1413pub use super :: generation:: ExternalFormatter ;
15- use super :: swc:: parse_swc_ast;
14+ use super :: generation:: generate;
15+ use super :: parse:: parse_ast;
1616
1717pub struct FormatTextOptions < ' a > {
1818 pub path : & ' a Path ,
@@ -70,7 +70,7 @@ pub fn format_text(options: FormatTextOptions) -> Result<Option<String>> {
7070 let file_text = if had_bom { file_text[ 3 ..] . to_string ( ) } else { file_text } ;
7171 let file_text: Arc < str > = file_text. into ( ) ;
7272 let allocator = Allocator :: default ( ) ;
73- let parsed_source = parse_swc_ast ( & allocator, file_path, file_extension, file_text) ?;
73+ let parsed_source = parse_ast ( & allocator, file_path, file_extension, file_text) ?;
7474 match inner_format ( & parsed_source, config, external_formatter) ? {
7575 Some ( new_text) => Ok ( Some ( new_text) ) ,
7676 None => {
@@ -85,7 +85,11 @@ pub fn format_text(options: FormatTextOptions) -> Result<Option<String>> {
8585}
8686
8787/// Formats an already parsed source. This is useful as a performance optimization.
88- pub fn format_parsed_source < ' a > ( source : & ' a ParsedSource < ' a > , config : & Configuration , external_formatter : Option < & ExternalFormatter > ) -> Result < Option < String > > {
88+ pub fn format_parsed_source < ' a > (
89+ source : & ' a ParsedSource < ' a > ,
90+ config : & Configuration ,
91+ external_formatter : Option < & ExternalFormatter > ,
92+ ) -> Result < Option < String > > {
8993 if super :: utils:: file_text_has_ignore_comment ( source. text ( ) , & config. ignore_file_comment_text ) {
9094 Ok ( None )
9195 } else {
@@ -119,7 +123,7 @@ fn inner_format<'a>(parsed_source: &'a ParsedSource<'a>, config: &Configuration,
119123#[ cfg( feature = "tracing" ) ]
120124pub fn trace_file ( file_path : & Path , file_text : & str , config : & Configuration ) -> dprint_core:: formatting:: TracingResult {
121125 let allocator = Allocator :: default ( ) ;
122- let parsed_source = parse_swc_ast ( & allocator, file_path, None , file_text. into ( ) ) . unwrap ( ) ;
126+ let parsed_source = parse_ast ( & allocator, file_path, None , file_text. into ( ) ) . unwrap ( ) ;
123127 ensure_no_specific_syntax_errors ( & parsed_source) . unwrap ( ) ;
124128 dprint_core:: formatting:: trace_printing ( || generate ( & parsed_source, config, None ) . unwrap ( ) , config_to_print_options ( file_text, config) )
125129}
0 commit comments