Skip to content

Commit d356392

Browse files
committed
refactor(formatter): Remove redundunt public API
1 parent ab16817 commit d356392

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

crates/oxc_formatter/examples/sort_imports.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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

crates/oxc_formatter/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)