22 * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
33 * This product includes software developed at Datadog (<https://www.datadoghq.com>/). Copyright 2025 Datadog, Inc.
44 **/
5- use swc_core:: ecma:: ast:: { FnDecl , FnExpr , Function } ;
5+ use swc_core:: ecma:: ast:: FnDecl ;
66
77#[ derive( Debug , Clone ) ]
88pub ( crate ) enum FunctionType {
@@ -25,14 +25,6 @@ impl FunctionKind {
2525 matches ! ( self , FunctionKind :: Async )
2626 }
2727
28- #[ must_use]
29- pub fn matches ( & self , func : & Function ) -> bool {
30- match self {
31- FunctionKind :: Sync => !func. is_async && !func. is_generator ,
32- FunctionKind :: Async => func. is_async && !func. is_generator ,
33- }
34- }
35-
3628 #[ must_use]
3729 pub fn tracing_operator ( & self ) -> & ' static str {
3830 match self {
@@ -202,22 +194,19 @@ impl FunctionQuery {
202194
203195 pub fn matches_decl ( & self , func : & FnDecl , count : & mut usize ) -> bool {
204196 let matches_except_count = matches ! ( self . typ( ) , FunctionType :: FunctionDeclaration )
205- && self . kind ( ) . matches ( & func. function )
206197 && func. ident . sym == self . name ( ) ;
207198 self . maybe_increment_count ( matches_except_count, count)
208199 }
209200
210- pub fn matches_expr ( & self , func : & FnExpr , count : & mut usize , name : & str ) -> bool {
211- let matches_except_count = matches ! ( self . typ( ) , FunctionType :: FunctionExpression )
212- && self . kind ( ) . matches ( & func. function )
213- && name == self . name ( ) ;
201+ pub fn matches_expr ( & self , count : & mut usize , name : & str ) -> bool {
202+ let matches_except_count =
203+ matches ! ( self . typ( ) , FunctionType :: FunctionExpression ) && name == self . name ( ) ;
214204 self . maybe_increment_count ( matches_except_count, count)
215205 }
216206
217- pub fn matches_method ( & self , func : & Function , count : & mut usize , name : & str ) -> bool {
218- let matches_except_count = matches ! ( self . typ( ) , FunctionType :: Method )
219- && self . kind ( ) . matches ( func)
220- && name == self . name ( ) ;
207+ pub fn matches_method ( & self , count : & mut usize , name : & str ) -> bool {
208+ let matches_except_count =
209+ matches ! ( self . typ( ) , FunctionType :: Method ) && name == self . name ( ) ;
221210 self . maybe_increment_count ( matches_except_count, count)
222211 }
223212}
0 commit comments