-
-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
e65764b
commit 2cd6eaf
Showing
24 changed files
with
826 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
crates/biome_css_formatter/src/css/any/starting_style_block.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//! 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::AnyCssStartingStyleBlock; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatAnyCssStartingStyleBlock; | ||
impl FormatRule<AnyCssStartingStyleBlock> for FormatAnyCssStartingStyleBlock { | ||
type Context = CssFormatContext; | ||
fn fmt(&self, node: &AnyCssStartingStyleBlock, f: &mut CssFormatter) -> FormatResult<()> { | ||
match node { | ||
AnyCssStartingStyleBlock::CssRuleListBlock(node) => node.format().fmt(f), | ||
AnyCssStartingStyleBlock::CssDeclarationListBlock(node) => node.format().fmt(f), | ||
AnyCssStartingStyleBlock::CssBogusBlock(node) => node.format().fmt(f), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
crates/biome_css_formatter/src/css/statements/starting_style_at_rule.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use crate::prelude::*; | ||
use biome_css_syntax::CssStartingStyleAtRule; | ||
use biome_rowan::AstNode; | ||
#[derive(Debug, Clone, Default)] | ||
pub(crate) struct FormatCssStartingStyleAtRule; | ||
impl FormatNodeRule<CssStartingStyleAtRule> for FormatCssStartingStyleAtRule { | ||
fn fmt_fields(&self, node: &CssStartingStyleAtRule, f: &mut CssFormatter) -> FormatResult<()> { | ||
format_verbatim_node(node.syntax()).fmt(f) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
crates/biome_css_parser/src/syntax/at_rule/starting_style.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
use crate::parser::CssParser; | ||
use crate::syntax::blocks::{ | ||
parse_or_recover_declaration_list_block, parse_or_recover_rule_list_block, | ||
}; | ||
use biome_css_syntax::CssSyntaxKind::*; | ||
use biome_css_syntax::T; | ||
use biome_parser::parsed_syntax::ParsedSyntax::Present; | ||
use biome_parser::prelude::ParsedSyntax::Absent; | ||
use biome_parser::prelude::*; | ||
|
||
/// Checks if the current token in the parser is a `@starting-style` at-rule. | ||
/// | ||
/// This function verifies if the current token matches the `@starting-style` rule, | ||
/// which is a custom at-rule used for specific parsing scenarios. | ||
#[inline] | ||
pub(crate) fn is_at_starting_style_at_rule(p: &mut CssParser) -> bool { | ||
p.at(T![starting_style]) | ||
} | ||
|
||
/// Parses a `@starting-style` at-rule in a CSS stylesheet. | ||
/// | ||
/// This function handles the parsing of a `@starting-style` at-rule, which is defined in the | ||
/// CSS Transitions Level 2 specification. It starts by confirming the presence of such a rule and then | ||
/// processes the content depending on whether the parser is currently inside a nesting block or at the root level. | ||
/// It employs different parsing strategies for declarations or rules based on the parser state `is_nesting_block`. | ||
/// | ||
/// Specification: [CSS Transitions Level 2 - @starting-style](https://drafts.csswg.org/css-transitions-2/#at-ruledef-starting-style) | ||
/// # Examples | ||
/// Basic usage in a CSS stylesheet: | ||
/// | ||
/// ```css | ||
/// // At the root level of a stylesheet | ||
/// @starting-style { | ||
/// /* rulesets */ | ||
/// } | ||
/// | ||
/// // Inside a selector | ||
/// selector { | ||
/// @starting-style { | ||
/// /* declarations */ | ||
/// } | ||
/// } | ||
/// ``` | ||
#[inline] | ||
pub(crate) fn parse_starting_style_at_rule(p: &mut CssParser) -> ParsedSyntax { | ||
if !is_at_starting_style_at_rule(p) { | ||
return Absent; | ||
} | ||
|
||
let m = p.start(); | ||
|
||
p.bump(T![starting_style]); | ||
|
||
let block = if p.state().is_nesting_block { | ||
parse_or_recover_declaration_list_block(p) | ||
} else { | ||
parse_or_recover_rule_list_block(p) | ||
}; | ||
|
||
if block.is_err() { | ||
return Present(m.complete(p, CSS_BOGUS_AT_RULE)); | ||
} | ||
|
||
Present(m.complete(p, CSS_STARTING_STYLE_AT_RULE)) | ||
} |
Oops, something went wrong.