From c67e811ac3728bff9af79d70405981d0340fb5a7 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sat, 27 Jul 2024 16:58:41 +0800 Subject: [PATCH] upgrade Raffia --- Cargo.lock | 4 +- malva/Cargo.toml | 2 +- malva/src/doc_gen/at_rule/mod.rs | 2 +- malva/src/doc_gen/selector.rs | 66 +++++++++++++++++--------------- 4 files changed, 39 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 488087f..15ea64a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -246,9 +246,9 @@ dependencies = [ [[package]] name = "raffia" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc828d8ecd0be424e6ea36ca6fca7190e4006ca3abbed660fc48a704284dcae0" +checksum = "f07b58921b49abb50d5d6ec283db5c8e71d2a80da16798a829077b4caf75fd9f" dependencies = [ "raffia_macro", "serde", diff --git a/malva/Cargo.toml b/malva/Cargo.toml index 43d125c..e047523 100644 --- a/malva/Cargo.toml +++ b/malva/Cargo.toml @@ -12,7 +12,7 @@ exclude = ["/tests"] aho-corasick = "1.1" itertools = "0.13" memchr = "2.7" -raffia = "0.7" +raffia = "0.8" serde = { version = "1.0", optional = true } tiny_pretty = "0.2" diff --git a/malva/src/doc_gen/at_rule/mod.rs b/malva/src/doc_gen/at_rule/mod.rs index 6349d9f..29a7732 100644 --- a/malva/src/doc_gen/at_rule/mod.rs +++ b/malva/src/doc_gen/at_rule/mod.rs @@ -70,7 +70,7 @@ impl<'s> DocGen<'s> for AtRulePrelude<'s> { AtRulePrelude::Namespace(namespace) => namespace.doc(ctx), AtRulePrelude::Nest(nest) => nest.doc(ctx).group().nest(ctx.indent_width), AtRulePrelude::Page(page) => page.doc(ctx), - AtRulePrelude::PositionFallback(position_fallback) => position_fallback.doc(ctx), + AtRulePrelude::PositionTry(position_try) => position_try.doc(ctx), AtRulePrelude::Property(property) => property.doc(ctx), AtRulePrelude::SassAtRoot(sass_at_root) => sass_at_root.doc(ctx), AtRulePrelude::SassContent(sass_content) => sass_content.doc(ctx), diff --git a/malva/src/doc_gen/selector.rs b/malva/src/doc_gen/selector.rs index 06923d0..84a3e5f 100644 --- a/malva/src/doc_gen/selector.rs +++ b/malva/src/doc_gen/selector.rs @@ -295,31 +295,31 @@ impl<'s> DocGen<'s> for PseudoClassSelector<'s> { if let Some(arg) = &self.arg { docs.push(Doc::text("(")); - let arg_span = arg.span(); + let arg_span = arg.kind.span(); let mut arg_doc = vec![]; if ctx.options.linebreak_in_pseudo_parens { arg_doc.push(Doc::line_or_nil()); } - arg_doc.extend(ctx.end_spaced_comments(self.span.start, arg_span.start)); - arg_doc.push(match arg { - PseudoClassSelectorArg::CompoundSelector(compound_selector) => { + arg_doc.extend(ctx.end_spaced_comments(arg.l_paren.end, arg_span.start)); + arg_doc.push(match &arg.kind { + PseudoClassSelectorArgKind::CompoundSelector(compound_selector) => { compound_selector.doc(ctx) } - PseudoClassSelectorArg::CompoundSelectorList(compound_selector_list) => { + PseudoClassSelectorArgKind::CompoundSelectorList(compound_selector_list) => { compound_selector_list.doc(ctx) } - PseudoClassSelectorArg::Ident(ident) => ident.doc(ctx), - PseudoClassSelectorArg::LanguageRangeList(language_range_list) => { + PseudoClassSelectorArgKind::Ident(ident) => ident.doc(ctx), + PseudoClassSelectorArgKind::LanguageRangeList(language_range_list) => { language_range_list.doc(ctx) } - PseudoClassSelectorArg::Nth(nth) => nth.doc(ctx), - PseudoClassSelectorArg::Number(number) => number.doc(ctx), - PseudoClassSelectorArg::RelativeSelectorList(relative_selector_list) => { + PseudoClassSelectorArgKind::Nth(nth) => nth.doc(ctx), + PseudoClassSelectorArgKind::Number(number) => number.doc(ctx), + PseudoClassSelectorArgKind::RelativeSelectorList(relative_selector_list) => { relative_selector_list.doc(ctx) } - PseudoClassSelectorArg::SelectorList(selector_list) => { + PseudoClassSelectorArgKind::SelectorList(selector_list) => { if ctx.options.linebreak_in_pseudo_parens { selector_list.doc(ctx).group().nest(ctx.indent_width) } else { @@ -331,18 +331,20 @@ impl<'s> DocGen<'s> for PseudoClassSelector<'s> { ) } } - PseudoClassSelectorArg::LessExtendList(less_extend_list) => { + PseudoClassSelectorArgKind::LessExtendList(less_extend_list) => { less_extend_list.doc(ctx) } - PseudoClassSelectorArg::TokenSeq(token_seq) => format_pseudo_selector_arg_tokens( - token_seq, - ctx, - token_seq.span.start, - token_seq.span.end, - ), + PseudoClassSelectorArgKind::TokenSeq(token_seq) => { + format_pseudo_selector_arg_tokens( + token_seq, + ctx, + token_seq.span.start, + token_seq.span.end, + ) + } }); - arg_doc.extend(ctx.start_spaced_comments(arg_span.end, self.span.end)); + arg_doc.extend(ctx.start_spaced_comments(arg_span.end, arg.r_paren.start)); if ctx.options.linebreak_in_pseudo_parens { docs.push( Doc::list(arg_doc) @@ -369,28 +371,30 @@ impl<'s> DocGen<'s> for PseudoElementSelector<'s> { if let Some(arg) = &self.arg { docs.push(Doc::text("(")); - let arg_span = arg.span(); + let arg_span = arg.kind.span(); let mut arg_doc = vec![]; if ctx.options.linebreak_in_pseudo_parens { arg_doc.push(Doc::line_or_nil()); } - arg_doc.extend(ctx.end_spaced_comments(self.span.start, arg_span.start)); - arg_doc.push(match arg { - PseudoElementSelectorArg::CompoundSelector(compound_selector) => { + arg_doc.extend(ctx.end_spaced_comments(arg.l_paren.end, arg_span.start)); + arg_doc.push(match &arg.kind { + PseudoElementSelectorArgKind::CompoundSelector(compound_selector) => { compound_selector.doc(ctx) } - PseudoElementSelectorArg::Ident(ident) => ident.doc(ctx), - PseudoElementSelectorArg::TokenSeq(token_seq) => format_pseudo_selector_arg_tokens( - token_seq, - ctx, - token_seq.span.start, - token_seq.span.end, - ), + PseudoElementSelectorArgKind::Ident(ident) => ident.doc(ctx), + PseudoElementSelectorArgKind::TokenSeq(token_seq) => { + format_pseudo_selector_arg_tokens( + token_seq, + ctx, + token_seq.span.start, + token_seq.span.end, + ) + } }); - arg_doc.extend(ctx.start_spaced_comments(arg_span.end, self.span.end)); + arg_doc.extend(ctx.start_spaced_comments(arg_span.end, arg.r_paren.start)); if ctx.options.linebreak_in_pseudo_parens { docs.push( Doc::list(arg_doc)