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

Method extract_call_reference

atomic-semantic/src/parser.rs:171–298  ·  view source on GitHub ↗

Extract a reference from a call expression

(
        &self,
        node: &Node,
        source: &str,
        file_path: &str,
        seen: &mut HashSet<(String, u32)>,
    )

Source from the content-addressed store, hash-verified

169
170 /// Extract a reference from a call expression
171 fn extract_call_reference(
172 &self,
173 node: &Node,
174 source: &str,
175 file_path: &str,
176 seen: &mut HashSet<(String, u32)>,
177 ) -> Option<Reference> {
178 // Get the function being called
179 let function_node = node.child_by_field_name("function")?;
180 let line = node.start_position().row as u32 + 1;
181
182 let symbol = match function_node.kind() {
183 "identifier" => {
184 // Direct call: foo()
185 function_node.utf8_text(source.as_bytes()).ok()?.to_string()
186 }
187 "member_expression" => {
188 // Method call: obj.method()
189 let property = function_node.child_by_field_name("property")?;
190 property.utf8_text(source.as_bytes()).ok()?.to_string()
191 }
192 _ => return None,
193 };
194
195 // Skip common built-ins
196 if matches!(
197 symbol.as_str(),
198 "console"
199 | "log"
200 | "error"
201 | "warn"
202 | "info"
203 | "debug"
204 | "toString"
205 | "valueOf"
206 | "push"
207 | "pop"
208 | "map"
209 | "filter"
210 | "reduce"
211 | "forEach"
212 | "find"
213 | "some"
214 | "every"
215 | "slice"
216 | "splice"
217 | "join"
218 | "split"
219 | "trim"
220 | "toLowerCase"
221 | "toUpperCase"
222 | "includes"
223 | "indexOf"
224 | "charAt"
225 | "substring"
226 | "replace"
227 | "match"
228 | "test"

Callers 1

Calls 7

kindMethod · 0.45
okMethod · 0.45
as_bytesMethod · 0.45
cloneMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected