From 866c5364a0a238943a79fa1c32153aa4f13b1eed Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Thu, 27 Jun 2024 18:27:45 -0300 Subject: [PATCH] simplify decorator arguments in the AST they are always strings so just return Str. We can switch back to Expr in the future, if we need it. --- crates/typst-syntax/src/ast.rs | 17 +++-------------- crates/typst/src/engine.rs | 5 +---- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs index 019ff4663..ae2ddd270 100644 --- a/crates/typst-syntax/src/ast.rs +++ b/crates/typst-syntax/src/ast.rs @@ -108,20 +108,9 @@ impl<'a> Decorator<'a> { } /// The decorator's arguments. - pub fn arguments(self) -> impl DoubleEndedIterator> { - let mut found_non_ident = false; - self.0 - .children() - .filter(move |node| { - // Skip the name (first identifier). - if node.is::() { - return found_non_ident; - } else if !node.kind().is_trivia() { - found_non_ident = true; - } - true - }) - .filter_map(Expr::from_untyped) + /// Currently, they are always strings. + pub fn arguments(self) -> impl DoubleEndedIterator> { + self.0.children().filter_map(Str::from_untyped) } } diff --git a/crates/typst/src/engine.rs b/crates/typst/src/engine.rs index 44e102430..5a26ce886 100644 --- a/crates/typst/src/engine.rs +++ b/crates/typst/src/engine.rs @@ -374,10 +374,7 @@ fn check_decorator_suppresses_warning( } for argument in decorator.arguments() { - let ast::Expr::Str(str) = argument else { - continue; - }; - if warning.name() == str.get() { + if warning.name() == argument.get() { return true; } }