Skip to content

Commit

Permalink
GritMetavariable => Metavariable
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Jul 31, 2024
1 parent b2ce9dc commit eac10f7
Show file tree
Hide file tree
Showing 66 changed files with 680 additions and 716 deletions.
12 changes: 6 additions & 6 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.

38 changes: 19 additions & 19 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.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl FormatRule<AnyCssDeclarationOrRule> for FormatAnyCssDeclarationOrRule {
AnyCssDeclarationOrRule::AnyCssRule(node) => node.format().fmt(f),
AnyCssDeclarationOrRule::CssBogus(node) => node.format().fmt(f),
AnyCssDeclarationOrRule::CssDeclarationWithSemicolon(node) => node.format().fmt(f),
AnyCssDeclarationOrRule::CssGritMetavariable(node) => node.format().fmt(f),
AnyCssDeclarationOrRule::CssMetavariable(node) => node.format().fmt(f),
}
}
}
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/any/media_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ impl FormatRule<AnyCssMediaQuery> for FormatAnyCssMediaQuery {
match node {
AnyCssMediaQuery::AnyCssMediaTypeQuery(node) => node.format().fmt(f),
AnyCssMediaQuery::CssBogusMediaQuery(node) => node.format().fmt(f),
AnyCssMediaQuery::CssGritMetavariable(node) => node.format().fmt(f),
AnyCssMediaQuery::CssMediaConditionQuery(node) => node.format().fmt(f),
AnyCssMediaQuery::CssMetavariable(node) => node.format().fmt(f),
}
}
}
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/any/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl FormatRule<AnyCssSelector> for FormatAnyCssSelector {
AnyCssSelector::CssBogusSelector(node) => node.format().fmt(f),
AnyCssSelector::CssComplexSelector(node) => node.format().fmt(f),
AnyCssSelector::CssCompoundSelector(node) => node.format().fmt(f),
AnyCssSelector::CssGritMetavariable(node) => node.format().fmt(f),
AnyCssSelector::CssMetavariable(node) => node.format().fmt(f),
}
}
}
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/any/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ impl FormatRule<AnyCssValue> for FormatAnyCssValue {
AnyCssValue::CssColor(node) => node.format().fmt(f),
AnyCssValue::CssCustomIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssDashedIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssGritMetavariable(node) => node.format().fmt(f),
AnyCssValue::CssIdentifier(node) => node.format().fmt(f),
AnyCssValue::CssMetavariable(node) => node.format().fmt(f),
AnyCssValue::CssNumber(node) => node.format().fmt(f),
AnyCssValue::CssRatio(node) => node.format().fmt(f),
AnyCssValue::CssString(node) => node.format().fmt(f),
Expand Down
12 changes: 0 additions & 12 deletions crates/biome_css_formatter/src/css/auxiliary/grit_metavariable.rs

This file was deleted.

10 changes: 10 additions & 0 deletions crates/biome_css_formatter/src/css/auxiliary/metavariable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::prelude::*;
use biome_css_syntax::CssMetavariable;
use biome_rowan::AstNode;
#[derive(Debug, Clone, Default)]
pub(crate) struct FormatCssMetavariable;
impl FormatNodeRule<CssMetavariable> for FormatCssMetavariable {
fn fmt_fields(&self, node: &CssMetavariable, f: &mut CssFormatter) -> FormatResult<()> {
format_verbatim_node(node.syntax()).fmt(f)
}
}
2 changes: 1 addition & 1 deletion crates/biome_css_formatter/src/css/auxiliary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub(crate) mod font_feature_values_block;
pub(crate) mod font_feature_values_item;
pub(crate) mod function;
pub(crate) mod generic_delimiter;
pub(crate) mod grit_metavariable;
pub(crate) mod import_anonymous_layer;
pub(crate) mod import_named_layer;
pub(crate) mod import_supports;
Expand All @@ -50,6 +49,7 @@ pub(crate) mod media_not_condition;
pub(crate) mod media_or_condition;
pub(crate) mod media_type;
pub(crate) mod media_type_query;
pub(crate) mod metavariable;
pub(crate) mod named_namespace_prefix;
pub(crate) mod namespace;
pub(crate) mod nested_qualified_rule;
Expand Down
80 changes: 40 additions & 40 deletions crates/biome_css_formatter/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1747,46 +1747,6 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssGenericProperty {
)
}
}
impl FormatRule<biome_css_syntax::CssGritMetavariable>
for crate::css::auxiliary::grit_metavariable::FormatCssGritMetavariable
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::CssGritMetavariable,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::CssGritMetavariable>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::CssGritMetavariable {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssGritMetavariable,
crate::css::auxiliary::grit_metavariable::FormatCssGritMetavariable,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::grit_metavariable::FormatCssGritMetavariable::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssGritMetavariable {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssGritMetavariable,
crate::css::auxiliary::grit_metavariable::FormatCssGritMetavariable,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::grit_metavariable::FormatCssGritMetavariable::default(),
)
}
}
impl FormatRule<biome_css_syntax::CssIdSelector>
for crate::css::selectors::id_selector::FormatCssIdSelector
{
Expand Down Expand Up @@ -2896,6 +2856,46 @@ impl IntoFormat<CssFormatContext> for biome_css_syntax::CssMediaTypeQuery {
)
}
}
impl FormatRule<biome_css_syntax::CssMetavariable>
for crate::css::auxiliary::metavariable::FormatCssMetavariable
{
type Context = CssFormatContext;
#[inline(always)]
fn fmt(
&self,
node: &biome_css_syntax::CssMetavariable,
f: &mut CssFormatter,
) -> FormatResult<()> {
FormatNodeRule::<biome_css_syntax::CssMetavariable>::fmt(self, node, f)
}
}
impl AsFormat<CssFormatContext> for biome_css_syntax::CssMetavariable {
type Format<'a> = FormatRefWithRule<
'a,
biome_css_syntax::CssMetavariable,
crate::css::auxiliary::metavariable::FormatCssMetavariable,
>;
fn format(&self) -> Self::Format<'_> {
#![allow(clippy::default_constructed_unit_structs)]
FormatRefWithRule::new(
self,
crate::css::auxiliary::metavariable::FormatCssMetavariable::default(),
)
}
}
impl IntoFormat<CssFormatContext> for biome_css_syntax::CssMetavariable {
type Format = FormatOwnedWithRule<
biome_css_syntax::CssMetavariable,
crate::css::auxiliary::metavariable::FormatCssMetavariable,
>;
fn into_format(self) -> Self::Format {
#![allow(clippy::default_constructed_unit_structs)]
FormatOwnedWithRule::new(
self,
crate::css::auxiliary::metavariable::FormatCssMetavariable::default(),
)
}
}
impl FormatRule<biome_css_syntax::CssNamedNamespacePrefix>
for crate::css::auxiliary::named_namespace_prefix::FormatCssNamedNamespacePrefix
{
Expand Down
6 changes: 2 additions & 4 deletions crates/biome_css_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,8 @@ impl<'src> CssLexer<'src> {
self.advance(1);
self.consume_byte(T!["$="])
}
UNI if self.options.is_grit_metavariable_enabled()
&& self.is_grit_metavariable_start() =>
{
self.consume_grit_metavariable(GRIT_METAVARIABLE)
UNI if self.options.is_metavariable_enabled() && self.is_metavariable_start() => {
self.consume_metavariable(GRIT_METAVARIABLE)
}
IDT | UNI | BSL if self.is_ident_start() => self.consume_identifier(),

Expand Down
4 changes: 2 additions & 2 deletions crates/biome_css_parser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl CssParserOptions {
}

/// Enables parsing of Grit metavariables.
pub fn allow_grit_metavariables(mut self) -> Self {
pub fn allow_metavariables(mut self) -> Self {
self.grit_metavariables = true;
self
}
Expand All @@ -60,7 +60,7 @@ impl CssParserOptions {
}

/// Checks if parsing of Grit metavariables is enabled.
pub fn is_grit_metavariable_enabled(&self) -> bool {
pub fn is_metavariable_enabled(&self) -> bool {
self.grit_metavariables
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_css_parser/src/syntax/at_rule/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::parser::CssParser;
use crate::syntax::at_rule::feature::parse_any_query_feature;
use crate::syntax::block::parse_conditional_block;
use crate::syntax::{
is_at_grit_metavariable, is_at_identifier, is_nth_at_identifier, parse_grit_metavariable,
is_at_identifier, is_at_metavariable, is_nth_at_identifier, parse_metavariable,
parse_regular_identifier,
};
use biome_css_syntax::CssSyntaxKind::*;
Expand Down Expand Up @@ -80,8 +80,8 @@ impl ParseSeparatedList for MediaQueryList {
fn parse_any_media_query(p: &mut CssParser) -> ParsedSyntax {
if is_at_media_type_query(p) {
parse_any_media_type_query(p)
} else if is_at_grit_metavariable(p) {
parse_grit_metavariable(p)
} else if is_at_metavariable(p) {
parse_metavariable(p)
} else if is_at_any_media_condition(p) {
let m = p.start();
parse_any_media_condition(p).ok(); // TODO handle error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use crate::syntax::at_rule::{is_at_at_rule, parse_at_rule};
use crate::syntax::block::ParseBlockBody;
use crate::syntax::parse_error::expected_any_declaration_or_at_rule;
use crate::syntax::{
is_at_declaration, is_at_grit_metavariable, is_at_nested_qualified_rule,
parse_declaration_with_semicolon, parse_grit_metavariable, parse_nested_qualified_rule,
try_parse,
is_at_declaration, is_at_metavariable, is_at_nested_qualified_rule,
parse_declaration_with_semicolon, parse_metavariable, parse_nested_qualified_rule, try_parse,
};
use biome_css_syntax::CssSyntaxKind::*;
use biome_css_syntax::{CssSyntaxKind, T};
Expand Down Expand Up @@ -39,7 +38,7 @@ fn is_at_declaration_or_rule_item(p: &mut CssParser) -> bool {
is_at_at_rule(p)
|| is_at_nested_qualified_rule(p)
|| is_at_declaration(p)
|| is_at_grit_metavariable(p)
|| is_at_metavariable(p)
}

struct DeclarationOrRuleListParseRecovery;
Expand Down Expand Up @@ -128,8 +127,8 @@ impl ParseNodeList for DeclarationOrRuleList {
parse_declaration_with_semicolon(p)
} else if is_at_nested_qualified_rule(p) {
parse_nested_qualified_rule(p)
} else if is_at_grit_metavariable(p) {
parse_grit_metavariable(p)
} else if is_at_metavariable(p) {
parse_metavariable(p)
} else {
Absent
}
Expand Down
16 changes: 8 additions & 8 deletions crates/biome_css_parser/src/syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,23 +249,23 @@ fn parse_declaration_important(p: &mut CssParser) -> ParsedSyntax {
}

#[inline]
fn is_at_grit_metavariable(p: &mut CssParser) -> bool {
fn is_at_metavariable(p: &mut CssParser) -> bool {
p.at(GRIT_METAVARIABLE)
}

#[inline]
fn is_nth_at_grit_metavariable(p: &mut CssParser, n: usize) -> bool {
fn is_nth_at_metavariable(p: &mut CssParser, n: usize) -> bool {
p.nth_at(n, GRIT_METAVARIABLE)
}

#[inline]
fn parse_grit_metavariable(p: &mut CssParser) -> ParsedSyntax {
if !is_at_grit_metavariable(p) {
fn parse_metavariable(p: &mut CssParser) -> ParsedSyntax {
if !is_at_metavariable(p) {
return Absent;
}
let m = p.start();
p.bump(GRIT_METAVARIABLE);
Present(m.complete(p, CSS_GRIT_METAVARIABLE))
Present(m.complete(p, CSS_METAVARIABLE))
}

#[inline]
Expand All @@ -279,7 +279,7 @@ pub(crate) fn is_at_any_value(p: &mut CssParser) -> bool {
|| is_at_ratio(p)
|| is_at_color(p)
|| is_at_bracketed_value(p)
|| is_at_grit_metavariable(p)
|| is_at_metavariable(p)
}

#[inline]
Expand All @@ -304,8 +304,8 @@ pub(crate) fn parse_any_value(p: &mut CssParser) -> ParsedSyntax {
parse_color(p)
} else if is_at_bracketed_value(p) {
parse_bracketed_value(p)
} else if is_at_grit_metavariable(p) {
parse_grit_metavariable(p)
} else if is_at_metavariable(p) {
parse_metavariable(p)
} else {
Absent
}
Expand Down
Loading

0 comments on commit eac10f7

Please sign in to comment.