Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 50 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.

73 changes: 73 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.

2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/css/any/at_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ impl FormatRule<AnyCssAtRule> for FormatAnyCssAtRule {
AnyCssAtRule::ScssEachAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssErrorAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssForAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssFunctionAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssIfAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssIncludeAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssMixinAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssReturnAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssWarnAtRule(node) => node.format().fmt(f),
AnyCssAtRule::ScssWhileAtRule(node) => node.format().fmt(f),
AnyCssAtRule::TwApplyAtRule(node) => node.format().fmt(f),
Expand Down
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 @@ -7457,6 +7457,44 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssForAtRule {
)
}
}
impl FormatRule<biome_css_syntax::ScssFunctionAtRule>
for crate::scss::statements::function_at_rule::FormatScssFunctionAtRule
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::ScssFunctionAtRule,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::ScssFunctionAtRule>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::ScssFunctionAtRule {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::ScssFunctionAtRule,
crate::scss::statements::function_at_rule::FormatScssFunctionAtRule,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::statements::function_at_rule::FormatScssFunctionAtRule::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssFunctionAtRule {
type Format = FormatOwnedWithRule<
biome_css_syntax::ScssFunctionAtRule,
crate::scss::statements::function_at_rule::FormatScssFunctionAtRule,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::statements::function_at_rule::FormatScssFunctionAtRule::default(),
)
}
}
impl FormatRule<biome_css_syntax::ScssIdentifier>
for crate::scss::value::identifier::FormatScssIdentifier
{
Expand Down Expand Up @@ -8119,6 +8157,44 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssQualifiedName {
)
}
}
impl FormatRule<biome_css_syntax::ScssReturnAtRule>
for crate::scss::statements::return_at_rule::FormatScssReturnAtRule
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::ScssReturnAtRule,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::ScssReturnAtRule>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::ScssReturnAtRule {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::ScssReturnAtRule,
crate::scss::statements::return_at_rule::FormatScssReturnAtRule,
>;
fn format(&self) -> Self::Format<'_> {
FormatRefWithRule::new(
self,
crate::scss::statements::return_at_rule::FormatScssReturnAtRule::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::ScssReturnAtRule {
type Format = FormatOwnedWithRule<
biome_css_syntax::ScssReturnAtRule,
crate::scss::statements::return_at_rule::FormatScssReturnAtRule,
>;
fn into_format(self) -> Self::Format {
FormatOwnedWithRule::new(
self,
crate::scss::statements::return_at_rule::FormatScssReturnAtRule::default(),
)
}
}
impl FormatRule<biome_css_syntax::ScssUnaryExpression>
for crate::scss::auxiliary::unary_expression::FormatScssUnaryExpression
{
Expand Down
29 changes: 29 additions & 0 deletions crates/biome_css_formatter/src/scss/statements/function_at_rule.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::prelude::*;
use biome_css_syntax::{ScssFunctionAtRule, ScssFunctionAtRuleFields};
use biome_formatter::write;

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

impl FormatNodeRule<ScssFunctionAtRule> for FormatScssFunctionAtRule {
fn fmt_fields(&self, node: &ScssFunctionAtRule, f: &mut CssFormatter) -> FormatResult<()> {
let ScssFunctionAtRuleFields {
function_token,
name,
parameters,
block,
} = node.as_fields();

write!(
f,
[
function_token.format(),
space(),
name.format(),
parameters.format(),
space(),
block.format()
]
)
Comment thread
denbezrukov marked this conversation as resolved.
}
}
2 changes: 2 additions & 0 deletions crates/biome_css_formatter/src/scss/statements/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ pub(crate) mod debug_at_rule;
pub(crate) mod each_at_rule;
pub(crate) mod error_at_rule;
pub(crate) mod for_at_rule;
pub(crate) mod function_at_rule;
pub(crate) mod if_at_rule;
pub(crate) mod include_at_rule;
pub(crate) mod mixin_at_rule;
pub(crate) mod return_at_rule;
pub(crate) mod warn_at_rule;
pub(crate) mod while_at_rule;
26 changes: 26 additions & 0 deletions crates/biome_css_formatter/src/scss/statements/return_at_rule.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use crate::prelude::*;
use biome_css_syntax::{ScssReturnAtRule, ScssReturnAtRuleFields};
use biome_formatter::write;

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

impl FormatNodeRule<ScssReturnAtRule> for FormatScssReturnAtRule {
fn fmt_fields(&self, node: &ScssReturnAtRule, f: &mut CssFormatter) -> FormatResult<()> {
let ScssReturnAtRuleFields {
return_token,
value,
semicolon_token,
} = node.as_fields();

write!(
f,
[
return_token.format(),
space(),
value.format(),
semicolon_token.format()
]
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@function
double(
$value:2,
$ratio: 1.5,
$rest...
){
@return
$value * $ratio;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: css/scss/at-rule/function.scss
---

# Input

```scss
@function
double(
$value:2,
$ratio: 1.5,
$rest...
){
@return
$value * $ratio;
}

```


=============================

# Outputs

## Output 1

-----
Indent style: Tab
Indent width: 2
Line ending: LF
Line width: 80
Quote style: Double Quotes
Trailing newline: true
-----

```scss
@function double($value: 2, $ratio: 1.5, $rest...) {
@return $value * $ratio;
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@return
$width * 2 ;
Loading
Loading