Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 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.

76 changes: 75 additions & 1 deletion 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.

76 changes: 76 additions & 0 deletions crates/biome_css_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6996,6 +6996,44 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssViewTransitionAtRuleD
FormatOwnedWithRule :: new (self , crate :: css :: auxiliary :: view_transition_at_rule_declarator :: FormatCssViewTransitionAtRuleDeclarator :: default ())
}
}
impl FormatRule<biome_css_syntax::ScssBinaryExpression>
for crate::scss::auxiliary::binary_expression::FormatScssBinaryExpression
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::ScssBinaryExpression,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::ScssBinaryExpression>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::ScssBinaryExpression {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::ScssBinaryExpression,
crate::scss::auxiliary::binary_expression::FormatScssBinaryExpression,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::auxiliary::binary_expression::FormatScssBinaryExpression::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssBinaryExpression {
type Format = FormatOwnedWithRule<
biome_css_syntax::ScssBinaryExpression,
crate::scss::auxiliary::binary_expression::FormatScssBinaryExpression,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::auxiliary::binary_expression::FormatScssBinaryExpression::default(),
)
}
}
impl FormatRule<biome_css_syntax::ScssDeclaration>
for crate::scss::auxiliary::declaration::FormatScssDeclaration
{
Expand Down Expand Up @@ -7440,6 +7478,44 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssQualifiedName {
)
}
}
impl FormatRule<biome_css_syntax::ScssUnaryExpression>
for crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::ScssUnaryExpression,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::ScssUnaryExpression>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::ScssUnaryExpression {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::ScssUnaryExpression,
crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssUnaryExpression {
type Format = FormatOwnedWithRule<
biome_css_syntax::ScssUnaryExpression,
crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression::default(),
)
}
}
impl FormatRule<biome_css_syntax::ScssVariableModifier>
for crate::scss::auxiliary::variable_modifier::FormatScssVariableModifier
{
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/scss/any/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ impl FormatRule<AnyScssExpression> for FormatAnyScssExpression {
fn fmt(&self, node: &AnyScssExpression, f: &mut CssFormatter) -> FormatResult<()> {
match node {
AnyScssExpression::AnyCssValue(node) => node.format().fmt(f),
AnyScssExpression::ScssBinaryExpression(node) => node.format().fmt(f),
AnyScssExpression::ScssExpression(node) => node.format().fmt(f),
AnyScssExpression::ScssListExpression(node) => node.format().fmt(f),
AnyScssExpression::ScssMapExpression(node) => node.format().fmt(f),
AnyScssExpression::ScssParenthesizedExpression(node) => node.format().fmt(f),
AnyScssExpression::ScssUnaryExpression(node) => node.format().fmt(f),
}
}
}
2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/scss/any/expression_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ impl FormatRule<AnyScssExpressionItem> for FormatAnyScssExpressionItem {
match node {
AnyScssExpressionItem::AnyCssValue(node) => node.format().fmt(f),
AnyScssExpressionItem::CssGenericDelimiter(node) => node.format().fmt(f),
AnyScssExpressionItem::ScssBinaryExpression(node) => node.format().fmt(f),
AnyScssExpressionItem::ScssListExpression(node) => node.format().fmt(f),
AnyScssExpressionItem::ScssMapExpression(node) => node.format().fmt(f),
AnyScssExpressionItem::ScssParenthesizedExpression(node) => node.format().fmt(f),
AnyScssExpressionItem::ScssUnaryExpression(node) => node.format().fmt(f),
}
}
}
27 changes: 27 additions & 0 deletions crates/biome_css_formatter/src/scss/auxiliary/binary_expression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use crate::prelude::*;
use biome_css_syntax::{ScssBinaryExpression, ScssBinaryExpressionFields};
use biome_formatter::{format_args, write};

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatScssBinaryExpression;

impl FormatNodeRule<ScssBinaryExpression> for FormatScssBinaryExpression {
fn fmt_fields(&self, node: &ScssBinaryExpression, f: &mut CssFormatter) -> FormatResult<()> {
let ScssBinaryExpressionFields {
left,
operator,
right,
} = node.as_fields();

write!(
f,
[group(&format_args![
left.format(),
space(),
operator.format(),
soft_line_break_or_space(),
right.format()
])]
)
}
}
2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/scss/auxiliary/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 binary_expression;
pub(crate) mod declaration;
pub(crate) mod expression;
pub(crate) mod list_expression;
Expand All @@ -10,4 +11,5 @@ pub(crate) mod nesting_declaration;
pub(crate) mod parent_selector_value;
pub(crate) mod parenthesized_expression;
pub(crate) mod qualified_name;
pub(crate) mod unary_expression;
pub(crate) mod variable_modifier;
29 changes: 29 additions & 0 deletions crates/biome_css_formatter/src/scss/auxiliary/unary_expression.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::prelude::*;
use biome_css_syntax::CssSyntaxKind;
use biome_css_syntax::{ScssUnaryExpression, ScssUnaryExpressionFields, T};
use biome_formatter::write;

#[derive(Debug, Clone, Default)]
pub(crate) struct FormatScssUnaryExpression;
impl FormatNodeRule<ScssUnaryExpression> for FormatScssUnaryExpression {
fn fmt_fields(&self, node: &ScssUnaryExpression, f: &mut CssFormatter) -> FormatResult<()> {
let ScssUnaryExpressionFields {
operator,
expression,
} = node.as_fields();
let operator = operator?;
let expression = expression?;

let is_parenthesized = matches!(
expression.syntax().kind(),
CssSyntaxKind::SCSS_PARENTHESIZED_EXPRESSION
);
let needs_space = matches!(operator.kind(), T![not]) && !is_parenthesized;

if needs_space {
write!(f, [operator.format(), space(), expression.format()])
} else {
write!(f, [operator.format(), expression.format()])
}
}
}
Loading
Loading