(node: Node<'_>, language: Language)
| 51 | } |
| 52 | |
| 53 | pub(crate) fn callable(node: Node<'_>, language: Language) -> bool { |
| 54 | match language { |
| 55 | Language::Rust => matches!( |
| 56 | node.kind(), |
| 57 | "function_item" | "function_signature_item" | "closure_expression" |
| 58 | ), |
| 59 | Language::TypeScript | Language::Tsx => matches!( |
| 60 | node.kind(), |
| 61 | "function_declaration" |
| 62 | | "generator_function_declaration" |
| 63 | | "function_expression" |
| 64 | | "function" |
| 65 | | "generator_function" |
| 66 | | "arrow_function" |
| 67 | | "method_definition" |
| 68 | | "abstract_method_signature" |
| 69 | | "method_signature" |
| 70 | ), |
| 71 | Language::Python => matches!(node.kind(), "function_definition" | "lambda"), |
| 72 | Language::Java => matches!( |
| 73 | node.kind(), |
| 74 | "method_declaration" |
| 75 | | "constructor_declaration" |
| 76 | | "compact_constructor_declaration" |
| 77 | | "lambda_expression" |
| 78 | ), |
| 79 | Language::Go => matches!( |
| 80 | node.kind(), |
| 81 | "function_declaration" | "method_declaration" | "func_literal" | "method_elem" |
| 82 | ), |
| 83 | Language::C | Language::Cpp => { |
| 84 | matches!(node.kind(), "function_definition" | "lambda_expression") |
| 85 | || (matches!(node.kind(), "field_declaration" | "declaration") |
| 86 | && declarator(node) |
| 87 | .and_then(|declaration| declaration.child_by_field_name("declarator")) |
| 88 | .is_some_and(|name| { |
| 89 | matches!( |
| 90 | name.kind(), |
| 91 | "identifier" |
| 92 | | "field_identifier" |
| 93 | | "qualified_identifier" |
| 94 | | "operator_name" |
| 95 | | "destructor_name" |
| 96 | ) |
| 97 | })) |
| 98 | } |
| 99 | Language::Swift => matches!( |
| 100 | node.kind(), |
| 101 | "function_declaration" |
| 102 | | "protocol_function_declaration" |
| 103 | | "init_declaration" |
| 104 | | "deinit_declaration" |
| 105 | | "lambda_literal" |
| 106 | ), |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | fn declarator(mut node: Node<'_>) -> Option<Node<'_>> { |
no test coverage detected