-
-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grit): complete formatting of all nodes
- Loading branch information
Showing
60 changed files
with
969 additions
and
414 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
70 changes: 35 additions & 35 deletions
70
crates/biome_grit_factory/src/generated/syntax_factory.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
use crate::prelude::*; | ||
use biome_formatter::write; | ||
use biome_grit_syntax::GritAnnotation; | ||
use biome_rowan::AstNode; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatGritAnnotation; | ||
impl FormatNodeRule<GritAnnotation> for FormatGritAnnotation { | ||
fn fmt_fields(&self, node: &GritAnnotation, f: &mut GritFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
write!(f, [node.value_token().format()]) | ||
} | ||
} |
43 changes: 23 additions & 20 deletions
43
crates/biome_grit_formatter/src/grit/auxiliary/sequential.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
use crate::prelude::*; | ||
use biome_grit_syntax::GritSequential; | ||
use biome_formatter::{write, FormatOptions}; | ||
use biome_grit_syntax::{GritSequential, GritSequentialFields}; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatGritSequential; | ||
impl FormatNodeRule<GritSequential> for FormatGritSequential { | ||
fn fmt_fields(&self, node: &GritSequential, f: &mut GritFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let GritSequentialFields { | ||
l_curly_token, | ||
sequential_token, | ||
sequential, | ||
r_curly_token, | ||
} = node.as_fields(); | ||
|
||
// TODO: investigate the verbatim panic when this code runs | ||
// let GritSequentialFields { | ||
// l_curly_token, | ||
// sequential_token, | ||
// sequential, | ||
// r_curly_token, | ||
// } = node.as_fields(); | ||
// | ||
// write!( | ||
// f, | ||
// [ | ||
// sequential_token.format(), | ||
// space(), | ||
// l_curly_token.format(), | ||
// sequential.format(), | ||
// r_curly_token.format() | ||
// ] | ||
// ) | ||
write!( | ||
f, | ||
[sequential_token.format(), space(), l_curly_token.format(),] | ||
)?; | ||
|
||
let should_insert_space_around_brackets = f.options().bracket_spacing().value(); | ||
write!( | ||
f, | ||
[group(&soft_block_indent_with_maybe_space( | ||
&sequential.format(), | ||
should_insert_space_around_brackets | ||
),)] | ||
)?; | ||
|
||
write!(f, [r_curly_token.format()]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
use crate::prelude::*; | ||
use biome_grit_syntax::GritWithin; | ||
use biome_rowan::AstNode; | ||
use biome_formatter::write; | ||
use biome_grit_syntax::{GritWithin, GritWithinFields}; | ||
|
||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatGritWithin; | ||
impl FormatNodeRule<GritWithin> for FormatGritWithin { | ||
fn fmt_fields(&self, node: &GritWithin, f: &mut GritFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let GritWithinFields { | ||
pattern, | ||
within_token, | ||
} = node.as_fields(); | ||
|
||
write!(f, [within_token.format(), space(), pattern.format()]) | ||
} | ||
} |
27 changes: 24 additions & 3 deletions
27
crates/biome_grit_formatter/src/grit/declarations/function_definition.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,31 @@ | ||
use crate::prelude::*; | ||
use biome_grit_syntax::GritFunctionDefinition; | ||
use biome_rowan::AstNode; | ||
use biome_formatter::write; | ||
use biome_grit_syntax::{GritFunctionDefinition, GritFunctionDefinitionFields}; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatGritFunctionDefinition; | ||
impl FormatNodeRule<GritFunctionDefinition> for FormatGritFunctionDefinition { | ||
fn fmt_fields(&self, node: &GritFunctionDefinition, f: &mut GritFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
let GritFunctionDefinitionFields { | ||
function_token, | ||
name, | ||
l_paren_token, | ||
args, | ||
r_paren_token, | ||
body, | ||
} = node.as_fields(); | ||
|
||
write!( | ||
f, | ||
[ | ||
function_token.format(), | ||
space(), | ||
name.format(), | ||
l_paren_token.format(), | ||
group(&args.format()), | ||
r_paren_token.format(), | ||
space(), | ||
body.format() | ||
] | ||
) | ||
} | ||
} |
Oops, something went wrong.