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

Method visit_for_calls_and_structure

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

Source from the content-addressed store, hash-verified

1514 }
1515
1516 fn visit_for_calls_and_structure(&mut self, node: Node<'t>) {
1517 stack_guard!();
1518 let kind = node.kind();
1519 self.maybe_capture_fn_refs(node);
1520
1521 if kind == "call_expression" {
1522 self.extract_call(node);
1523 } else if kind == "new_expression" {
1524 self.extract_instantiation(node);
1525 }
1526
1527 // C++ stack construction `Calculator calc(0)` / `Widget w{1,2}` (#1035).
1528 if kind == "declaration"
1529 && self.variant == Variant::Cpp
1530 && self.is_cpp_stack_construction(node)
1531 {
1532 self.extract_instantiation(node);
1533 }
1534
1535 // C++ local fn-pointer bindings: declarations and branch reassignments.
1536 if self.variant == Variant::Cpp && !self.stack.is_empty() {
1537 if kind == "declaration" {
1538 for i in 0..node.named_child_count() {
1539 let Some(child) = node.named_child(i) else { continue };
1540 if child.kind() != "init_declarator" {
1541 continue;
1542 }
1543 let Some(decl) = child.child_by_field_name("declarator") else { continue };
1544 if decl.kind() != "identifier" {
1545 continue;
1546 }
1547 let local = self.text(decl).to_string();
1548 self.record_cpp_fn_ptr_binding(&local, child.child_by_field_name("value"));
1549 }
1550 } else if kind == "assignment_expression" {
1551 if let Some(left) = node.child_by_field_name("left") {
1552 if left.kind() == "identifier" {
1553 let local = self.text(left).to_string();
1554 self.record_cpp_fn_ptr_binding(&local, node.child_by_field_name("right"));
1555 }
1556 }
1557 }
1558 }
1559
1560 // Static-member / value-read: `Foo.BAR`, `Foo->x` (cpp).
1561 self.extract_static_member_ref(node);
1562
1563 // Nested NAMED functions become their own nodes.
1564 if kind == "function_definition" {
1565 let nested_name = self.extract_name(node);
1566 if !nested_name.is_empty() && nested_name != "<anonymous>" {
1567 self.extract_function(node);
1568 return;
1569 }
1570 }
1571
1572 // Structural nodes inside bodies (local classes; macro-misparse rescue).
1573 if self.variant == Variant::Cpp && kind == "class_specifier" {

Callers 1

visit_function_bodyMethod · 0.45

Calls 12

textMethod · 0.65
maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
extract_nameMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45

Tested by

no test coverage detected