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

Method extract_inheritance

codegraph-kernel/src/ccpp/mod.rs:1580–1617  ·  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

1578 /// grammars: base_class_clause (#1043), the field_declaration Go-embedding
1579 /// shape, and the field_declaration_list recursion that reaches it.
1580 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1581 let extends_kind = edge_kind_index("extends").unwrap();
1582 for i in 0..node.named_child_count() {
1583 let Some(child) = node.named_child(i) else { continue };
1584 match child.kind() {
1585 "base_class_clause" => {
1586 for j in 0..child.named_child_count() {
1587 let Some(t) = child.named_child(j) else { continue };
1588 if matches!(
1589 t.kind(),
1590 "type_identifier" | "qualified_identifier" | "template_type"
1591 ) {
1592 let name = strip_cpp_template_args(self.text(t));
1593 self.push_ref_at(class_row, &name, extends_kind, t);
1594 }
1595 }
1596 }
1597 "field_declaration" => {
1598 let has_field_identifier = (0..child.named_child_count())
1599 .filter_map(|j| child.named_child(j))
1600 .any(|c| c.kind() == "field_identifier");
1601 if !has_field_identifier {
1602 let type_id = (0..child.named_child_count())
1603 .filter_map(|j| child.named_child(j))
1604 .find(|c| c.kind() == "type_identifier");
1605 if let Some(type_id) = type_id {
1606 let name = self.text(type_id).to_string();
1607 self.push_ref_at(class_row, &name, extends_kind, type_id);
1608 }
1609 }
1610 }
1611 "field_declaration_list" | "class_heritage" => {
1612 self.extract_inheritance(child, class_row);
1613 }
1614 _ => {}
1615 }
1616 }
1617 }
1618
1619 // --- fn-ref capture (#756, cFamilySpec) ----------------------------------
1620

Callers 4

extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 5

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

Tested by

no test coverage detected