MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / extract_call_expression_sites

Function extract_call_expression_sites

src/extraction/common.rs:133–165  ·  view source on GitHub ↗
(
    source: &[u8],
    file_path: &str,
    unresolved_refs: &mut Vec<UnresolvedRef>,
    node: TsNode<'_>,
    fn_node_id: &str,
)

Source from the content-addressed store, hash-verified

131/// references, taking the callee name from the first named child.
132#[allow(dead_code)]
133pub(crate) fn extract_call_expression_sites(
134 source: &[u8],
135 file_path: &str,
136 unresolved_refs: &mut Vec<UnresolvedRef>,
137 node: TsNode<'_>,
138 fn_node_id: &str,
139) {
140 let mut cursor = node.walk();
141 if cursor.goto_first_child() {
142 loop {
143 let child = cursor.node();
144 if child.kind() == "call_expression" {
145 // Get the callee: the first named child (usually an identifier)
146 if let Some(callee) = child.named_child(0) {
147 let callee_name = node_text(source, callee);
148 unresolved_refs.push(UnresolvedRef {
149 from_node_id: fn_node_id.to_string(),
150 reference_name: callee_name,
151 reference_kind: EdgeKind::Calls,
152 line: child.start_position().row as u32,
153 column: child.start_position().column as u32,
154 file_path: file_path.to_string(),
155 });
156 }
157 }
158 // Recurse for nested calls.
159 extract_call_expression_sites(source, file_path, unresolved_refs, child, fn_node_id);
160 if !cursor.goto_next_sibling() {
161 break;
162 }
163 }
164 }
165}

Callers 4

extract_call_sitesMethod · 0.85
extract_call_sitesMethod · 0.85
extract_call_sitesMethod · 0.85
extract_call_sitesMethod · 0.85

Calls 3

node_textFunction · 0.85
kindMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected