Skip to content

Commit

Permalink
feat(printer) Print TryStatement (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Nov 13, 2023
1 parent 2adfec6 commit 3db074b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions crates/oxc_prettier/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,27 @@ impl<'a> Format<'a> for LabeledStatement<'a> {
}

impl<'a> Format<'a> for TryStatement<'a> {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
let mut parts = p.vec();
parts.push(string!(p, "try "));

parts.push(format!(p, self.block));

if let Some(handler) = &self.handler {
parts.push(string!(p, " "));
parts.push(format!(p, handler));
}

if let Some(finalizer) = &self.finalizer {
parts.push(string!(p, " finally "));
parts.push(format!(p, finalizer));
}

Doc::Array(parts)
}
}

impl<'a> Format<'a> for CatchClause<'a> {
fn format(&self, p: &mut Prettier<'a>) -> Doc<'a> {
Doc::Line
}
Expand Down

0 comments on commit 3db074b

Please sign in to comment.