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

Method extract_inheritance

codegraph-kernel/src/swift.rs:1114–1132  ·  view source on GitHub ↗

extractInheritance — the swift inheritance_specifier case: FIRST type_identifier of each specifier's user_type, everything as `extends` (conformances included; `: Module.Base` takes `Module`).

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

Source from the content-addressed store, hash-verified

1112 /// type_identifier of each specifier's user_type, everything as `extends`
1113 /// (conformances included; `: Module.Base` takes `Module`).
1114 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1115 let extends_kind = edge_kind_index("extends").unwrap();
1116 for i in 0..node.named_child_count() {
1117 let Some(child) = node.named_child(i) else { continue };
1118 if child.kind() != "inheritance_specifier" {
1119 continue;
1120 }
1121 let user_type = (0..child.named_child_count())
1122 .filter_map(|j| child.named_child(j))
1123 .find(|c| c.kind() == "user_type");
1124 let Some(user_type) = user_type else { continue };
1125 let type_id = (0..user_type.named_child_count())
1126 .filter_map(|j| user_type.named_child(j))
1127 .find(|c| c.kind() == "type_identifier");
1128 let Some(type_id) = type_id else { continue };
1129 let name = self.text(type_id).to_string();
1130 self.push_ref_at(class_row, &name, extends_kind, type_id);
1131 }
1132 }
1133
1134 /// extractTypeAnnotations — generic path: the 'parameter' field NEVER
1135 /// resolves (zero param refs), 'return_type' DOES; the direct

Callers 4

extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_interfaceMethod · 0.45

Calls 4

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

Tested by

no test coverage detected