Skip to content

Commit

Permalink
chore(css_formatter): create NodeConcept::Property to group propert…
Browse files Browse the repository at this point in the history
…y nodes (#1400)
  • Loading branch information
faultyserver authored Jan 2, 2024
1 parent 010de23 commit 3c24e4c
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 59 deletions.
7 changes: 0 additions & 7 deletions crates/biome_css_formatter/src/css/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub(crate) mod attribute_matcher;
pub(crate) mod attribute_matcher_value;
pub(crate) mod attribute_name;
pub(crate) mod binary_expression;
pub(crate) mod color;
pub(crate) mod container_and_query;
pub(crate) mod container_not_query;
pub(crate) mod container_or_query;
Expand All @@ -15,16 +14,12 @@ pub(crate) mod container_style_in_parens;
pub(crate) mod container_style_not_query;
pub(crate) mod container_style_or_query;
pub(crate) mod container_style_query_in_parens;
pub(crate) mod custom_identifier;
pub(crate) mod dashed_identifier;
pub(crate) mod declaration;
pub(crate) mod declaration_important;
pub(crate) mod declaration_list_block;
pub(crate) mod declaration_or_at_rule_block;
pub(crate) mod declaration_with_semicolon;
pub(crate) mod generic_delimiter;
pub(crate) mod generic_property;
pub(crate) mod identifier;
pub(crate) mod keyframes_block;
pub(crate) mod keyframes_item;
pub(crate) mod layer_declaration;
Expand All @@ -43,7 +38,6 @@ pub(crate) mod named_namespace_prefix;
pub(crate) mod namespace;
pub(crate) mod nth_offset;
pub(crate) mod page_at_rule_block;
pub(crate) mod page_selector_pseudo;
pub(crate) mod parameter;
pub(crate) mod parenthesized_expression;
pub(crate) mod query_feature_boolean;
Expand All @@ -67,4 +61,3 @@ pub(crate) mod supports_not_condition;
pub(crate) mod supports_or_condition;
pub(crate) mod universal_namespace_prefix;
pub(crate) mod url_function;
pub(crate) mod url_value_raw;
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pub(crate) mod any;
pub(crate) mod auxiliary;
pub(crate) mod bogus;
pub(crate) mod lists;
pub(crate) mod properties;
pub(crate) mod pseudo;
pub(crate) mod selectors;
pub(crate) mod statements;
Expand Down
3 changes: 3 additions & 0 deletions crates/biome_css_formatter/src/css/properties/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod generic_property;
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/pseudo/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod page_selector_pseudo;
pub(crate) mod pseudo_class_function_compound_selector_list;
pub(crate) mod pseudo_class_function_identifier;
pub(crate) mod pseudo_class_function_nth;
Expand Down
5 changes: 5 additions & 0 deletions crates/biome_css_formatter/src/css/value/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.
pub(crate) mod color;
pub(crate) mod custom_identifier;
pub(crate) mod dashed_identifier;
pub(crate) mod identifier;
pub(crate) mod number;
pub(crate) mod percentage;
pub(crate) mod ratio;
pub(crate) mod regular_dimension;
pub(crate) mod string;
pub(crate) mod unknown_dimension;
pub(crate) mod url_value_raw;
85 changes: 37 additions & 48 deletions crates/biome_css_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssNamespace {
}
}
impl FormatRule<biome_css_syntax::CssIdentifier>
for crate::css::auxiliary::identifier::FormatCssIdentifier
for crate::css::value::identifier::FormatCssIdentifier
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -505,26 +505,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssIdentifier {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssIdentifier,
crate::css::auxiliary::identifier::FormatCssIdentifier,
crate::css::value::identifier::FormatCssIdentifier,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::identifier::FormatCssIdentifier::default(),
crate::css::value::identifier::FormatCssIdentifier::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssIdentifier {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssIdentifier,
crate::css::auxiliary::identifier::FormatCssIdentifier,
crate::css::value::identifier::FormatCssIdentifier,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::identifier::FormatCssIdentifier::default(),
crate::css::value::identifier::FormatCssIdentifier::default(),
)
}
}
Expand Down Expand Up @@ -603,7 +603,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssUniversalNamespacePre
}
}
impl FormatRule<biome_css_syntax::CssCustomIdentifier>
for crate::css::auxiliary::custom_identifier::FormatCssCustomIdentifier
for crate::css::value::custom_identifier::FormatCssCustomIdentifier
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -619,26 +619,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssCustomIdentifier {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssCustomIdentifier,
crate::css::auxiliary::custom_identifier::FormatCssCustomIdentifier,
crate::css::value::custom_identifier::FormatCssCustomIdentifier,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::custom_identifier::FormatCssCustomIdentifier::default(),
crate::css::value::custom_identifier::FormatCssCustomIdentifier::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssCustomIdentifier {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssCustomIdentifier,
crate::css::auxiliary::custom_identifier::FormatCssCustomIdentifier,
crate::css::value::custom_identifier::FormatCssCustomIdentifier,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::custom_identifier::FormatCssCustomIdentifier::default(),
crate::css::value::custom_identifier::FormatCssCustomIdentifier::default(),
)
}
}
Expand Down Expand Up @@ -1608,7 +1608,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssDeclarationImportant
}
}
impl FormatRule<biome_css_syntax::CssGenericProperty>
for crate::css::auxiliary::generic_property::FormatCssGenericProperty
for crate::css::properties::generic_property::FormatCssGenericProperty
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -1624,26 +1624,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssGenericProperty {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssGenericProperty,
crate::css::auxiliary::generic_property::FormatCssGenericProperty,
crate::css::properties::generic_property::FormatCssGenericProperty,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::generic_property::FormatCssGenericProperty::default(),
crate::css::properties::generic_property::FormatCssGenericProperty::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssGenericProperty {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssGenericProperty,
crate::css::auxiliary::generic_property::FormatCssGenericProperty,
crate::css::properties::generic_property::FormatCssGenericProperty,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::generic_property::FormatCssGenericProperty::default(),
crate::css::properties::generic_property::FormatCssGenericProperty::default(),
)
}
}
Expand Down Expand Up @@ -1688,7 +1688,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssGenericDelimiter {
}
}
impl FormatRule<biome_css_syntax::CssDashedIdentifier>
for crate::css::auxiliary::dashed_identifier::FormatCssDashedIdentifier
for crate::css::value::dashed_identifier::FormatCssDashedIdentifier
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -1704,26 +1704,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssDashedIdentifier {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssDashedIdentifier,
crate::css::auxiliary::dashed_identifier::FormatCssDashedIdentifier,
crate::css::value::dashed_identifier::FormatCssDashedIdentifier,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::dashed_identifier::FormatCssDashedIdentifier::default(),
crate::css::value::dashed_identifier::FormatCssDashedIdentifier::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssDashedIdentifier {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssDashedIdentifier,
crate::css::auxiliary::dashed_identifier::FormatCssDashedIdentifier,
crate::css::value::dashed_identifier::FormatCssDashedIdentifier,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::dashed_identifier::FormatCssDashedIdentifier::default(),
crate::css::value::dashed_identifier::FormatCssDashedIdentifier::default(),
)
}
}
Expand Down Expand Up @@ -3359,7 +3359,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssPageSelector {
}
}
impl FormatRule<biome_css_syntax::CssPageSelectorPseudo>
for crate::css::auxiliary::page_selector_pseudo::FormatCssPageSelectorPseudo
for crate::css::pseudo::page_selector_pseudo::FormatCssPageSelectorPseudo
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -3375,26 +3375,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssPageSelectorPseudo {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssPageSelectorPseudo,
crate::css::auxiliary::page_selector_pseudo::FormatCssPageSelectorPseudo,
crate::css::pseudo::page_selector_pseudo::FormatCssPageSelectorPseudo,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::page_selector_pseudo::FormatCssPageSelectorPseudo::default(),
crate::css::pseudo::page_selector_pseudo::FormatCssPageSelectorPseudo::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssPageSelectorPseudo {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssPageSelectorPseudo,
crate::css::auxiliary::page_selector_pseudo::FormatCssPageSelectorPseudo,
crate::css::pseudo::page_selector_pseudo::FormatCssPageSelectorPseudo,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::page_selector_pseudo::FormatCssPageSelectorPseudo::default(),
crate::css::pseudo::page_selector_pseudo::FormatCssPageSelectorPseudo::default(),
)
}
}
Expand Down Expand Up @@ -3976,38 +3976,27 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssScopeEdge {
)
}
}
impl FormatRule<biome_css_syntax::CssColor> for crate::css::auxiliary::color::FormatCssColor {
impl FormatRule<biome_css_syntax::CssColor> for crate::css::value::color::FormatCssColor {
type Context = CssFormatContext;
#[inline(always)]
fn fmt(&self, node: &biome_css_syntax::CssColor, f: &mut CssFormatter) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::CssColor>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::CssColor {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssColor,
crate::css::auxiliary::color::FormatCssColor,
>;
type Format<'a> =
FormatRefWithRule<'a, biome_css_syntax::CssColor, crate::css::value::color::FormatCssColor>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::color::FormatCssColor::default(),
)
FormatRefWithRule::new(self, crate::css::value::color::FormatCssColor::default())
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssColor {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssColor,
crate::css::auxiliary::color::FormatCssColor,
>;
type Format =
FormatOwnedWithRule<biome_css_syntax::CssColor, crate::css::value::color::FormatCssColor>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::color::FormatCssColor::default(),
)
FormatOwnedWithRule::new(self, crate::css::value::color::FormatCssColor::default())
}
}
impl FormatRule<biome_css_syntax::CssRegularDimension>
Expand Down Expand Up @@ -4131,7 +4120,7 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssUrlFunction {
}
}
impl FormatRule<biome_css_syntax::CssUrlValueRaw>
for crate::css::auxiliary::url_value_raw::FormatCssUrlValueRaw
for crate::css::value::url_value_raw::FormatCssUrlValueRaw
{
type Context = CssFormatContext;
#[inline(always)]
Expand All @@ -4147,26 +4136,26 @@ impl AsFormat<CssFormatContext> for biome_css_syntax::CssUrlValueRaw {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssUrlValueRaw,
crate::css::auxiliary::url_value_raw::FormatCssUrlValueRaw,
crate::css::value::url_value_raw::FormatCssUrlValueRaw,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::url_value_raw::FormatCssUrlValueRaw::default(),
crate::css::value::url_value_raw::FormatCssUrlValueRaw::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssUrlValueRaw {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssUrlValueRaw,
crate::css::auxiliary::url_value_raw::FormatCssUrlValueRaw,
crate::css::value::url_value_raw::FormatCssUrlValueRaw,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::url_value_raw::FormatCssUrlValueRaw::default(),
crate::css::value::url_value_raw::FormatCssUrlValueRaw::default(),
)
}
}
Expand Down
2 changes: 2 additions & 0 deletions xtask/codegen/css.ungram
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,8 @@ CssScopeEdge =
// AUXILIARY
///////////////

// When adding values here, add them as `NodeConcept::Value` in the
// `name_to_module` function in `src/formatter.rs`.
AnyCssValue =
CssIdentifier
| CssCustomIdentifier
Expand Down
Loading

0 comments on commit 3c24e4c

Please sign in to comment.