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

Method extract_inheritance

codegraph-kernel/src/swift.rs:1222–1240  ·  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

1220 /// type_identifier of each specifier's user_type, everything as `extends`
1221 /// (conformances included; `: Module.Base` takes `Module`).
1222 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1223 let extends_kind = edge_kind_index("extends").unwrap();
1224 for i in 0..node.named_child_count() {
1225 let Some(child) = node.named_child(i) else { continue };
1226 if child.kind() != "inheritance_specifier" {
1227 continue;
1228 }
1229 let user_type = (0..child.named_child_count())
1230 .filter_map(|j| child.named_child(j))
1231 .find(|c| c.kind() == "user_type");
1232 let Some(user_type) = user_type else { continue };
1233 let type_id = (0..user_type.named_child_count())
1234 .filter_map(|j| user_type.named_child(j))
1235 .find(|c| c.kind() == "type_identifier");
1236 let Some(type_id) = type_id else { continue };
1237 let name = self.text(type_id).to_string();
1238 self.push_ref_at(class_row, &name, extends_kind, type_id);
1239 }
1240 }
1241
1242 /// extractTypeAnnotations — generic path: the 'parameter' field NEVER
1243 /// 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
textMethod · 0.65
unwrapMethod · 0.60
push_ref_atMethod · 0.45

Tested by

no test coverage detected