From 3db074b87cd6ee95cb2feb2e44d8a77a5202c090 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 13 Nov 2023 19:16:05 +0000 Subject: [PATCH] feat(printer) Print `TryStatement` (#1277) --- crates/oxc_prettier/src/format.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/oxc_prettier/src/format.rs b/crates/oxc_prettier/src/format.rs index 733a998ad..fcfc1274d 100644 --- a/crates/oxc_prettier/src/format.rs +++ b/crates/oxc_prettier/src/format.rs @@ -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 }