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

Method extract_inheritance

codegraph-kernel/src/ccpp/mod.rs:1602–1640  ·  view source on GitHub ↗

extractInheritance — the branches whose node kinds occur in the c/cpp grammars: base_class_clause (#1043), the field_declaration Go-embedding shape, and the field_declaration_list recursion that reaches it.

(&mut self, node: Node<'t>, class_row: u32)

Source from the content-addressed store, hash-verified

1600 /// grammars: base_class_clause (#1043), the field_declaration Go-embedding
1601 /// shape, and the field_declaration_list recursion that reaches it.
1602 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1603 stack_guard!();
1604 let extends_kind = edge_kind_index("extends").unwrap();
1605 for i in 0..node.named_child_count() {
1606 let Some(child) = node.named_child(i) else { continue };
1607 match child.kind() {
1608 "base_class_clause" => {
1609 for j in 0..child.named_child_count() {
1610 let Some(t) = child.named_child(j) else { continue };
1611 if matches!(
1612 t.kind(),
1613 "type_identifier" | "qualified_identifier" | "template_type"
1614 ) {
1615 let name = strip_cpp_template_args(self.text(t));
1616 self.push_ref_at(class_row, &name, extends_kind, t);
1617 }
1618 }
1619 }
1620 "field_declaration" => {
1621 let has_field_identifier = (0..child.named_child_count())
1622 .filter_map(|j| child.named_child(j))
1623 .any(|c| c.kind() == "field_identifier");
1624 if !has_field_identifier {
1625 let type_id = (0..child.named_child_count())
1626 .filter_map(|j| child.named_child(j))
1627 .find(|c| c.kind() == "type_identifier");
1628 if let Some(type_id) = type_id {
1629 let name = self.text(type_id).to_string();
1630 self.push_ref_at(class_row, &name, extends_kind, type_id);
1631 }
1632 }
1633 }
1634 "field_declaration_list" | "class_heritage" => {
1635 self.extract_inheritance(child, class_row);
1636 }
1637 _ => {}
1638 }
1639 }
1640 }
1641
1642 // --- fn-ref capture (#756, cFamilySpec) ----------------------------------
1643

Callers 4

extract_classMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 5

edge_kind_indexFunction · 0.85
strip_cpp_template_argsFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
push_ref_atMethod · 0.45

Tested by

no test coverage detected