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

Method extract_inheritance

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

1124 /// type_identifier of each specifier's user_type, everything as `extends`
1125 /// (conformances included; `: Module.Base` takes `Module`).
1126 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1127 let extends_kind = edge_kind_index("extends").unwrap();
1128 for i in 0..node.named_child_count() {
1129 let Some(child) = node.named_child(i) else { continue };
1130 if child.kind() != "inheritance_specifier" {
1131 continue;
1132 }
1133 let user_type = (0..child.named_child_count())
1134 .filter_map(|j| child.named_child(j))
1135 .find(|c| c.kind() == "user_type");
1136 let Some(user_type) = user_type else { continue };
1137 let type_id = (0..user_type.named_child_count())
1138 .filter_map(|j| user_type.named_child(j))
1139 .find(|c| c.kind() == "type_identifier");
1140 let Some(type_id) = type_id else { continue };
1141 let name = self.text(type_id).to_string();
1142 self.push_ref_at(class_row, &name, extends_kind, type_id);
1143 }
1144 }
1145
1146 /// extractTypeAnnotations — generic path: the 'parameter' field NEVER
1147 /// 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