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:1499–1573  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

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

Callers 1

visit_function_bodyMethod · 0.45

Calls 12

maybe_capture_fn_refsMethod · 0.45
extract_callMethod · 0.45
extract_instantiationMethod · 0.45
textMethod · 0.45
extract_nameMethod · 0.45
extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45

Tested by

no test coverage detected