mirror of
https://github.com/typst/typst
synced 2025-05-16 10:05:28 +08:00
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.
This commit is contained in:
parent
181c633fe5
commit
866c5364a0
@ -108,20 +108,9 @@ impl<'a> Decorator<'a> {
|
||||
}
|
||||
|
||||
/// The decorator's arguments.
|
||||
pub fn arguments(self) -> impl DoubleEndedIterator<Item = Expr<'a>> {
|
||||
let mut found_non_ident = false;
|
||||
self.0
|
||||
.children()
|
||||
.filter(move |node| {
|
||||
// Skip the name (first identifier).
|
||||
if node.is::<Ident>() {
|
||||
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<Item = Str<'a>> {
|
||||
self.0.children().filter_map(Str::from_untyped)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user