1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use crate::prelude::*;

use biome_formatter::write;
use biome_js_syntax::JsTryStatement;
use biome_js_syntax::JsTryStatementFields;

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatJsTryStatement;

impl FormatNodeRule<JsTryStatement> for FormatJsTryStatement {
    fn fmt_fields(&self, node: &JsTryStatement, f: &mut JsFormatter) -> FormatResult<()> {
        let JsTryStatementFields {
            try_token,
            body,
            catch_clause,
        } = node.as_fields();

        write![
            f,
            [
                try_token.format(),
                space(),
                body.format(),
                space(),
                catch_clause.format(),
            ]
        ]
    }
}