From 45ab8abf76aa8157b43f3c7675b11fb51fac66d9 Mon Sep 17 00:00:00 2001 From: Akshay Date: Fri, 15 Oct 2021 13:06:29 +0530 Subject: allow match_kind to accept multiple kinds --- macros/src/lib.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'macros/src') diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c33fcba..127b4cb 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -139,6 +139,12 @@ fn generate_match_with_fn(meta: &LintMeta) -> TokenStream2 { #match_path == *with } } + } else if let syn::Expr::Array(array_expr) = match_with_lit { + quote! { + fn match_with(&self, with: &SyntaxKind) -> bool { + #array_expr.contains(with) + } + } } else { panic!("`match_with` has non-path value") } @@ -151,8 +157,14 @@ fn generate_match_kind(meta: &LintMeta) -> TokenStream2 { .unwrap_or_else(|| panic!("`match_with` not present")); if let syn::Expr::Path(match_path) = match_with_lit { quote! { - fn match_kind(&self) -> SyntaxKind { - #match_path + fn match_kind(&self) -> Vec { + vec![#match_path] + } + } + } else if let syn::Expr::Array(array_expr) = match_with_lit { + quote! { + fn match_kind(&self) -> Vec { + #array_expr.to_vec() } } } else { -- cgit v1.2.3