Skip to content

Commit

Permalink
feat(css_parser): css modules composes (#3017)
Browse files Browse the repository at this point in the history
  • Loading branch information
denbezrukov committed May 30, 2024
1 parent 32d73c4 commit 508a914
Show file tree
Hide file tree
Showing 39 changed files with 2,567 additions and 82 deletions.
66 changes: 66 additions & 0 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.

88 changes: 88 additions & 0 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.

15 changes: 15 additions & 0 deletions crates/biome_css_formatter/src/css/any/composes_import_source.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

use crate::prelude::*;
use biome_css_syntax::AnyCssComposesImportSource;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatAnyCssComposesImportSource;
impl FormatRule<AnyCssComposesImportSource> for FormatAnyCssComposesImportSource {
type Context = CssFormatContext;
fn fmt(&self, node: &AnyCssComposesImportSource, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssComposesImportSource::CssIdentifier(node) => node.format().fmt(f),
AnyCssComposesImportSource::CssString(node) => node.format().fmt(f),
}
}
}
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/any/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub(crate) mod at_rule;
pub(crate) mod attribute_matcher_value;
pub(crate) mod composes_import_source;
pub(crate) mod compound_selector;
pub(crate) mod container_and_combinable_query;
pub(crate) mod container_or_combinable_query;
Expand Down
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/any/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ impl FormatRule<AnyCssProperty> for FormatAnyCssProperty {
fn fmt(&self, node: &AnyCssProperty, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyCssProperty::CssBogusProperty(node) => node.format().fmt(f),
AnyCssProperty::CssComposesProperty(node) => node.format().fmt(f),
AnyCssProperty::CssGenericProperty(node) => node.format().fmt(f),
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::prelude::*;
use biome_css_syntax::{CssComposesImportSpecifier, CssComposesImportSpecifierFields};
use biome_formatter::write;

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

write![f, [space(), from_token.format(), space(), source.format()]]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use crate::prelude::*;
use biome_css_syntax::{CssComposesPropertyValue, CssComposesPropertyValueFields};
use biome_formatter::write;

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

write![f, [classes.format(), specifier.format()]]
}
}
2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/css/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ pub(crate) mod attribute_matcher;
pub(crate) mod attribute_matcher_value;
pub(crate) mod attribute_name;
pub(crate) mod binary_expression;
pub(crate) mod composes_import_specifier;
pub(crate) mod composes_property_value;
pub(crate) mod container_and_query;
pub(crate) mod container_not_query;
pub(crate) mod container_or_query;
Expand Down
12 changes: 12 additions & 0 deletions crates/biome_css_formatter/src/css/lists/composes_class_list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use crate::prelude::*;
use biome_css_syntax::CssComposesClassList;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatCssComposesClassList;
impl FormatRule<CssComposesClassList> for FormatCssComposesClassList {
type Context = CssFormatContext;
fn fmt(&self, node: &CssComposesClassList, f: &mut CssFormatter) -> FormatResult<()> {
f.join_with(&space())
.entries(node.iter().formatted())
.finish()
}
}
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/lists/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

pub(crate) mod component_value_list;
pub(crate) mod composes_class_list;
pub(crate) mod compound_selector_list;
pub(crate) mod custom_identifier_list;
pub(crate) mod declaration_list;
Expand Down
18 changes: 18 additions & 0 deletions crates/biome_css_formatter/src/css/properties/composes_property.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::prelude::*;
use biome_css_syntax::{CssComposesProperty, CssComposesPropertyFields};
use biome_formatter::write;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatCssComposesProperty;
impl FormatNodeRule<CssComposesProperty> for FormatCssComposesProperty {
fn fmt_fields(&self, node: &CssComposesProperty, f: &mut CssFormatter) -> FormatResult<()> {
let CssComposesPropertyFields {
name,
colon_token,
value,
} = node.as_fields();
write!(
f,
[name.format(), colon_token.format(), space(), value.format()]
)
}
}
1 change: 1 addition & 0 deletions crates/biome_css_formatter/src/css/properties/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! This is a generated file. Don't modify it by hand! Run 'cargo codegen formatter' to re-generate the file.

pub(crate) mod composes_property;
pub(crate) mod generic_property;
pub(crate) mod value_at_rule_generic_property;
Loading

0 comments on commit 508a914

Please sign in to comment.