use crate::parser::CssParser;
use biome_css_syntax::{CssSyntaxKind, TextRange, T};
use biome_parser::diagnostic::{expect_one_of, ParseDiagnostic, ToDiagnostic};
use biome_parser::{token_set, Parser, TokenSet};
pub(crate) const CSS_MODULES_SCOPE_SET: TokenSet<CssSyntaxKind> = token_set![T![global], T![local]];
pub(crate) fn local_or_global_not_allowed(p: &CssParser, range: TextRange) -> ParseDiagnostic {
p.err_builder(
"`:local` and `:global` pseudo-classes are not standard CSS features.",
range,
)
.with_hint(
"You can enable `:local` and `:global` pseudo-class parsing by setting the `css.parser.cssModules` option to `true` in your configuration file.",
)
}
pub(crate) fn expected_any_css_module_scope(p: &CssParser, range: TextRange) -> ParseDiagnostic {
expect_one_of(&["global", "local"], range).into_diagnostic(p)
}
pub(crate) fn composes_not_allowed(p: &CssParser, range: TextRange) -> ParseDiagnostic {
p.err_builder(
"`composes` declaration is not a standard CSS feature.",
range,
)
.with_hint(
"You can enable `composes` declaration parsing by setting the `css.parser.cssModules` option to `true` in your configuration file.",
)
}
pub(crate) fn expected_composes_import_source(p: &CssParser, range: TextRange) -> ParseDiagnostic {
expect_one_of(&["<identifier>", "<string>"], range).into_diagnostic(p)
}
pub(crate) fn expected_classes_list(p: &CssParser, range: TextRange) -> ParseDiagnostic {
p.err_builder(
"Expected a non-empty list of classes after `composes`.",
range,
)
}