Skip to content

Commit

Permalink
feat(css_parser,css_formatter): distinguish regular, custom, and dash…
Browse files Browse the repository at this point in the history
…ed identifiers (#1353)
  • Loading branch information
faultyserver authored Dec 28, 2023
1 parent 8253bc0 commit f77d796
Show file tree
Hide file tree
Showing 89 changed files with 1,209 additions and 1,448 deletions.
84 changes: 19 additions & 65 deletions crates/biome_css_factory/src/generated/node_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 30 additions & 84 deletions crates/biome_css_factory/src/generated/syntax_factory.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/any/declaration_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ impl FormatRule<AnyCssDeclarationName> for FormatAnyCssDeclarationName {
fn fmt(&self, node: &AnyCssDeclarationName, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssDeclarationName::CssIdentifier(node) => node.format().fmt(f),
AnyCssDeclarationName::CssCustomProperty(node) => node.format().fmt(f),
AnyCssDeclarationName::CssDashedIdentifier(node) => node.format().fmt(f),
}
}
}
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/any/keyframe_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl FormatRule<AnyCssKeyframeName> for FormatAnyCssKeyframeName {
type Context = CssFormatContext;
fn fmt(&self, node: &AnyCssKeyframeName, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssKeyframeName::CssIdentifier(node) => node.format().fmt(f),
AnyCssKeyframeName::CssCustomIdentifier(node) => node.format().fmt(f),
AnyCssKeyframeName::CssString(node) => node.format().fmt(f),
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/biome_css_formatter/src/css/any/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ impl FormatRule<AnyCssValue> for FormatAnyCssValue {
fn fmt(&self, node: &AnyCssValue, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssValue::CssIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssCustomIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssDashedIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssString(node) => node.format().fmt(f),
AnyCssValue::CssNumber(node) => node.format().fmt(f),
AnyCssValue::AnyCssDimension(node) => node.format().fmt(f),
AnyCssValue::CssRatio(node) => node.format().fmt(f),
AnyCssValue::AnyCssFunction(node) => node.format().fmt(f),
AnyCssValue::CssCustomProperty(node) => node.format().fmt(f),
AnyCssValue::CssColor(node) => node.format().fmt(f),
}
}
Expand Down
13 changes: 13 additions & 0 deletions crates/biome_css_formatter/src/css/auxiliary/custom_identifier.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
use crate::prelude::*;
use biome_css_syntax::{CssCustomIdentifier, CssCustomIdentifierFields};
use biome_formatter::write;

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatCssCustomIdentifier;
impl FormatNodeRule<CssCustomIdentifier> for FormatCssCustomIdentifier {
fn fmt_fields(&self, node: &CssCustomIdentifier, f: &mut CssFormatter) -> FormatResult<()> {
let CssCustomIdentifierFields { value_token } = node.as_fields();

write!(f, [value_token.format()])
}
}
Loading

0 comments on commit f77d796

Please sign in to comment.