MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / extract_call

Method extract_call

codegraph-kernel/src/ccpp/mod.rs:1660–1798  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

1658 // --- calls / instantiation ----------------------------------------------
1659
1660 fn extract_call(&mut self, node: Node<'t>) {
1661 if self.stack.is_empty() {
1662 return;
1663 }
1664 let caller_row = self.top_row();
1665 let func = node
1666 .child_by_field_name("function")
1667 .or_else(|| node.named_child(0));
1668 let calls_kind = edge_kind_index("calls").unwrap();
1669
1670 // C++ explicit operator call `a.operator+(b)` (#1247): the
1671 // operator_name hides in an ERROR child. (has_error() defers such
1672 // files to wasm, so this scan is a faithful no-op today.)
1673 if self.variant == Variant::Cpp {
1674 if let Some(func) = func {
1675 let mut operator_name = String::new();
1676 'err: for i in 0..node.named_child_count() {
1677 let Some(child) = node.named_child(i) else { continue };
1678 if child.kind() != "ERROR" {
1679 continue;
1680 }
1681 for op in child.named_children(&mut child.walk()) {
1682 if op.kind() == "operator_name" {
1683 operator_name = self.text(op).to_string();
1684 break 'err;
1685 }
1686 }
1687 }
1688 if !operator_name.is_empty() {
1689 let sym = operator_name["operator".len()..].trim().to_string();
1690 if symbolic_op_re().is_match(&sym) {
1691 let compact: String = sym.chars().filter(|c| !c.is_whitespace()).collect();
1692 operator_name = format!("operator{compact}");
1693 }
1694 let receiver = arrow_dot_no_ws(self.text(func));
1695 if receiver != "this" && !operator_receiver_re().is_match(&receiver) {
1696 return;
1697 }
1698 let callee = if receiver == "this" {
1699 operator_name
1700 } else {
1701 format!("{receiver}.{operator_name}")
1702 };
1703 self.push_ref_at(caller_row, &callee, calls_kind, node);
1704 return;
1705 }
1706 }
1707 }
1708
1709 let mut callee_name = String::new();
1710 if let Some(func) = func {
1711 if func.kind() == "field_expression" {
1712 // `obj.method()` / `ptr->method()` — the `field` field.
1713 let property = func
1714 .child_by_field_name("property")
1715 .or_else(|| func.child_by_field_name("field"))
1716 .or_else(|| func.named_child(1));
1717 if let Some(property) = property {

Callers 2

dispatch_nodeMethod · 0.45

Calls 15

edge_kind_indexFunction · 0.85
symbolic_op_reFunction · 0.85
arrow_dot_no_wsFunction · 0.85
operator_receiver_reFunction · 0.85
strip_cpp_template_argsFunction · 0.85
lenMethod · 0.80
mapMethod · 0.80
is_literal_receiverFunction · 0.70
simple_ident_reFunction · 0.70
textMethod · 0.65
getMethod · 0.65
unwrapMethod · 0.60

Tested by

no test coverage detected