Skip to content

Commit

Permalink
Update formatting for definition list
Browse files Browse the repository at this point in the history
  • Loading branch information
branberry committed Sep 30, 2024
1 parent f783130 commit 9b1757e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
12 changes: 11 additions & 1 deletion crates/biome_grit_formatter/src/grit/lists/definition_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ pub(crate) struct FormatGritDefinitionList;
impl FormatRule<GritDefinitionList> for FormatGritDefinitionList {
type Context = GritFormatContext;
fn fmt(&self, node: &GritDefinitionList, f: &mut GritFormatter) -> FormatResult<()> {
format_verbatim_node(node.syntax()).fmt(f)
let mut join = f.join_nodes_with_hardline();

for definition in node {
let def_clone = definition.clone().unwrap();
join.entry(
definition?.syntax(),
&format_or_verbatim(def_clone.format()),
);
}

join.finish()
}
}
19 changes: 16 additions & 3 deletions crates/biome_grit_formatter/src/grit/patterns/pattern_where.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
use crate::prelude::*;
use biome_grit_syntax::GritPatternWhere;
use biome_rowan::AstNode;
use biome_formatter::write;
use biome_grit_syntax::{GritPatternWhere, GritPatternWhereFields};

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatGritPatternWhere;
impl FormatNodeRule<GritPatternWhere> for FormatGritPatternWhere {
fn fmt_fields(&self, node: &GritPatternWhere, f: &mut GritFormatter) -> FormatResult<()> {
format_verbatim_node(node.syntax()).fmt(f)
let GritPatternWhereFields {
pattern,
side_condition,
where_token,
} = node.as_fields();
write!(
f,
[
pattern.format(),
side_condition.format(),
where_token.format()
]
)
}
}

0 comments on commit 9b1757e

Please sign in to comment.