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

Method extract_inheritance

codegraph-kernel/src/rustlang.rs:1150–1192  ·  view source on GitHub ↗

extractInheritance — the rust-reachable cases: trait_bounds (supertraits; a scoped `fmt::Debug` bound matches NO case and is dropped) and the field_declaration_list recursion. The TS Go-embedding check on field_declaration is gated to Go (and was inert here anyway — every rust field has a field_identifier).

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

Source from the content-addressed store, hash-verified

1148 /// check on field_declaration is gated to Go (and was inert here anyway —
1149 /// every rust field has a field_identifier).
1150 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1151 stack_guard!();
1152 let extends_kind = edge_kind_index("extends").unwrap();
1153 for child in node.named_children(&mut node.walk()) {
1154 match child.kind() {
1155 "trait_bounds" => {
1156 for bound in child.named_children(&mut child.walk()) {
1157 let type_node: Option<Node> = match bound.kind() {
1158 "type_identifier" => Some(bound),
1159 "generic_type" => (0..bound.named_child_count())
1160 .filter_map(|k| bound.named_child(k))
1161 .find(|c| c.kind() == "type_identifier"),
1162 "higher_ranked_trait_bound" => {
1163 let generic = (0..bound.named_child_count())
1164 .filter_map(|k| bound.named_child(k))
1165 .find(|c| c.kind() == "generic_type");
1166 generic
1167 .and_then(|g| {
1168 (0..g.named_child_count())
1169 .filter_map(|k| g.named_child(k))
1170 .find(|c| c.kind() == "type_identifier")
1171 })
1172 .or_else(|| {
1173 (0..bound.named_child_count())
1174 .filter_map(|k| bound.named_child(k))
1175 .find(|c| c.kind() == "type_identifier")
1176 })
1177 }
1178 _ => None, // scoped_type_identifier: dropped (quirk)
1179 };
1180 if let Some(tn) = type_node {
1181 let name = self.text(tn).to_string();
1182 self.push_ref_at(class_row, &name, extends_kind, tn);
1183 }
1184 }
1185 }
1186 "field_declaration_list" | "class_heritage" => {
1187 self.extract_inheritance(child, class_row);
1188 }
1189 _ => {}
1190 }
1191 }
1192 }
1193
1194 /// extractRustImplItem — `impl Trait for Type` back-reference from the
1195 /// grammar's `trait` / `type` fields (#1588; an inherent impl has no

Callers 3

extract_interfaceMethod · 0.45
extract_aggregateMethod · 0.45
extract_enumMethod · 0.45

Calls 5

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

Tested by

no test coverage detected