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

Method extract_inheritance

codegraph-kernel/src/go.rs:849–884  ·  view source on GitHub ↗

extractInheritance — the Go branches: interface embedding (constraint_elem) and struct embedding (field_declaration without a field_identifier), plus the field_declaration_list recursion.

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

Source from the content-addressed store, hash-verified

847 /// (constraint_elem) and struct embedding (field_declaration without a
848 /// field_identifier), plus the field_declaration_list recursion.
849 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
850 stack_guard!();
851 let extends_kind = edge_kind_index("extends").unwrap();
852 for i in 0..node.named_child_count() {
853 let Some(child) = node.named_child(i) else { continue };
854 match child.kind() {
855 "constraint_elem" => {
856 let type_id = (0..child.named_child_count())
857 .filter_map(|j| child.named_child(j))
858 .find(|c| c.kind() == "type_identifier");
859 if let Some(type_id) = type_id {
860 let name = self.text(type_id).to_string();
861 self.push_ref_at(class_row, &name, extends_kind, type_id);
862 }
863 }
864 "field_declaration" => {
865 let has_field_identifier = (0..child.named_child_count())
866 .filter_map(|j| child.named_child(j))
867 .any(|c| c.kind() == "field_identifier");
868 if !has_field_identifier {
869 let type_id = (0..child.named_child_count())
870 .filter_map(|j| child.named_child(j))
871 .find(|c| c.kind() == "type_identifier");
872 if let Some(type_id) = type_id {
873 let name = self.text(type_id).to_string();
874 self.push_ref_at(class_row, &name, extends_kind, type_id);
875 }
876 }
877 }
878 "field_declaration_list" | "class_heritage" => {
879 self.extract_inheritance(child, class_row);
880 }
881 _ => {}
882 }
883 }
884 }
885
886 /// extractTypeAnnotations — Go's returnField is `result`.
887 fn extract_type_annotations(&mut self, node: Node<'t>, from_row: u32) {

Callers 1

extract_type_aliasMethod · 0.45

Calls 4

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

Tested by

no test coverage detected