MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / callable

Function callable

atomic-audit/src/extract/languages.rs:53–108  ·  view source on GitHub ↗
(node: Node<'_>, language: Language)

Source from the content-addressed store, hash-verified

51}
52
53pub(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
110fn declarator(mut node: Node<'_>) -> Option<Node<'_>> {

Callers 10

parseFunction · 0.70
owner_classFunction · 0.70
qualifiedFunction · 0.70
control_flowFunction · 0.70
in_functionFunction · 0.70
public_surfaceFunction · 0.70
code_linesFunction · 0.70
guard_across_awaitFunction · 0.50
inspectFunction · 0.50
inspect_viewsFunction · 0.50

Calls 1

declaratorFunction · 0.85

Tested by

no test coverage detected