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

Method extract_call_name

atomic-semantic/src/parsers/rust.rs:543–576  ·  view source on GitHub ↗

Extract the simple function name from the callee sub-node of a `call_expression`. Returns `None` for call targets we cannot name simply (closures, raw pointers, etc.).

(&self, func_node: &Node, source: &str)

Source from the content-addressed store, hash-verified

541 ///
542 /// Returns `None` for call targets we cannot name simply (closures, raw pointers, etc.).
543 fn extract_call_name(&self, func_node: &Node, source: &str) -> Option<String> {
544 match func_node.kind() {
545 "identifier" => {
546 let name = self.node_text(func_node, source);
547 if name.is_empty() {
548 None
549 } else {
550 Some(name)
551 }
552 }
553 "field_expression" => {
554 // self.method() or obj.method() — extract just "method"
555 func_node
556 .child_by_field_name("field")
557 .map(|f| self.node_text(&f, source))
558 .filter(|s| !s.is_empty())
559 }
560 "scoped_identifier" => {
561 // Module::func() — extract just "func"
562 func_node
563 .child_by_field_name("name")
564 .map(|n| self.node_text(&n, source))
565 .filter(|s| !s.is_empty())
566 }
567 "generic_function" => {
568 // func::<T>() — recurse into the inner function node
569 func_node
570 .child_by_field_name("function")
571 .as_ref()
572 .and_then(|f| self.extract_call_name(f, source))
573 }
574 _ => None,
575 }
576 }
577}
578
579impl Default for RustParser {

Callers 1

walk_tree_for_callsMethod · 0.45

Calls 4

as_refMethod · 0.80
kindMethod · 0.45
node_textMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected