aboutsummaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-10-15 08:36:29 +0100
committerAkshay <[email protected]>2021-10-15 08:36:29 +0100
commit45ab8abf76aa8157b43f3c7675b11fb51fac66d9 (patch)
tree6a2d7f6e52069b69e303381e9f89a32950d41a3b /macros
parentc6ea58410cb6145cf2791f0ae0d1918cf0d5bc62 (diff)
allow match_kind to accept multiple kinds
Diffstat (limited to 'macros')
-rw-r--r--macros/src/lib.rs16
1 files changed, 14 insertions, 2 deletions
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 {
139 #match_path == *with 139 #match_path == *with
140 } 140 }
141 } 141 }
142 } else if let syn::Expr::Array(array_expr) = match_with_lit {
143 quote! {
144 fn match_with(&self, with: &SyntaxKind) -> bool {
145 #array_expr.contains(with)
146 }
147 }
142 } else { 148 } else {
143 panic!("`match_with` has non-path value") 149 panic!("`match_with` has non-path value")
144 } 150 }
@@ -151,8 +157,14 @@ fn generate_match_kind(meta: &LintMeta) -> TokenStream2 {
151 .unwrap_or_else(|| panic!("`match_with` not present")); 157 .unwrap_or_else(|| panic!("`match_with` not present"));
152 if let syn::Expr::Path(match_path) = match_with_lit { 158 if let syn::Expr::Path(match_path) = match_with_lit {
153 quote! { 159 quote! {
154 fn match_kind(&self) -> SyntaxKind { 160 fn match_kind(&self) -> Vec<SyntaxKind> {
155 #match_path 161 vec![#match_path]
162 }
163 }
164 } else if let syn::Expr::Array(array_expr) = match_with_lit {
165 quote! {
166 fn match_kind(&self) -> Vec<SyntaxKind> {
167 #array_expr.to_vec()
156 } 168 }
157 } 169 }
158 } else { 170 } else {