From c645bd7cede054075f0facbc0922c00b544df4f1 Mon Sep 17 00:00:00 2001 From: Denis Bezrukov <6227442+denbezrukov@users.noreply.github.com> Date: Sat, 22 Jun 2024 17:36:54 +0300 Subject: [PATCH] fix(css_parser): fix Constant crashes when editing css files #3256 --- crates/biome_css_parser/src/syntax/mod.rs | 3 +-- crates/biome_css_parser/src/syntax/property/color.rs | 6 +++--- crates/biome_css_parser/src/syntax/property/mod.rs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/biome_css_parser/src/syntax/mod.rs b/crates/biome_css_parser/src/syntax/mod.rs index 5eb597db92ba..dab4e9945035 100644 --- a/crates/biome_css_parser/src/syntax/mod.rs +++ b/crates/biome_css_parser/src/syntax/mod.rs @@ -11,6 +11,7 @@ use crate::parser::CssParser; use crate::syntax::at_rule::{is_at_at_rule, parse_at_rule}; use crate::syntax::block::parse_declaration_or_rule_list_block; use crate::syntax::parse_error::{expected_any_rule, expected_non_css_wide_keyword_identifier}; +use crate::syntax::property::color::{is_at_color, parse_color}; use crate::syntax::property::unicode_range::{is_at_unicode_range, parse_unicode_range}; use crate::syntax::property::{is_at_any_property, parse_any_property}; use crate::syntax::selector::is_nth_at_selector; @@ -24,10 +25,8 @@ use biome_parser::parse_recovery::{ParseRecovery, ParseRecoveryTokenSet, Recover use biome_parser::prelude::ParsedSyntax; use biome_parser::prelude::ParsedSyntax::{Absent, Present}; use biome_parser::{token_set, Parser}; -use biome_parser::diagnostic::expected_token; use value::dimension::{is_at_any_dimension, parse_any_dimension}; use value::function::{is_at_any_function, parse_any_function}; -use crate::syntax::property::color::{is_at_color, parse_color}; use self::parse_error::{expected_component_value, expected_declaration_item}; diff --git a/crates/biome_css_parser/src/syntax/property/color.rs b/crates/biome_css_parser/src/syntax/property/color.rs index dd302eb049d9..50f3eb13d2c8 100644 --- a/crates/biome_css_parser/src/syntax/property/color.rs +++ b/crates/biome_css_parser/src/syntax/property/color.rs @@ -1,11 +1,11 @@ +use crate::lexer::CssLexContext; +use crate::parser::CssParser; use biome_css_syntax::CssSyntaxKind::{CSS_COLOR, CSS_COLOR_LITERAL}; -use biome_css_syntax::{T, TextRange}; +use biome_css_syntax::{TextRange, T}; use biome_parser::diagnostic::{expected_node, ParseDiagnostic}; use biome_parser::parsed_syntax::ParsedSyntax; use biome_parser::parsed_syntax::ParsedSyntax::{Absent, Present}; use biome_parser::Parser; -use crate::lexer::CssLexContext; -use crate::parser::CssParser; #[inline] pub(crate) fn is_at_color(p: &mut CssParser) -> bool { diff --git a/crates/biome_css_parser/src/syntax/property/mod.rs b/crates/biome_css_parser/src/syntax/property/mod.rs index c2e02e7814ea..36e1fe69404b 100644 --- a/crates/biome_css_parser/src/syntax/property/mod.rs +++ b/crates/biome_css_parser/src/syntax/property/mod.rs @@ -1,5 +1,5 @@ -pub(crate) mod unicode_range; pub(crate) mod color; +pub(crate) mod unicode_range; use crate::lexer::CssLexContext; use crate::parser::CssParser;