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

Method extract_inheritance

codegraph-kernel/src/rustlang.rs:1125–1167  ·  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

1123 /// check on field_declaration is gated to Go (and was inert here anyway —
1124 /// every rust field has a field_identifier).
1125 fn extract_inheritance(&mut self, node: Node<'t>, class_row: u32) {
1126 stack_guard!();
1127 let extends_kind = edge_kind_index("extends").unwrap();
1128 for child in node.named_children(&mut node.walk()) {
1129 match child.kind() {
1130 "trait_bounds" => {
1131 for bound in child.named_children(&mut child.walk()) {
1132 let type_node: Option<Node> = match bound.kind() {
1133 "type_identifier" => Some(bound),
1134 "generic_type" => (0..bound.named_child_count())
1135 .filter_map(|k| bound.named_child(k))
1136 .find(|c| c.kind() == "type_identifier"),
1137 "higher_ranked_trait_bound" => {
1138 let generic = (0..bound.named_child_count())
1139 .filter_map(|k| bound.named_child(k))
1140 .find(|c| c.kind() == "generic_type");
1141 generic
1142 .and_then(|g| {
1143 (0..g.named_child_count())
1144 .filter_map(|k| g.named_child(k))
1145 .find(|c| c.kind() == "type_identifier")
1146 })
1147 .or_else(|| {
1148 (0..bound.named_child_count())
1149 .filter_map(|k| bound.named_child(k))
1150 .find(|c| c.kind() == "type_identifier")
1151 })
1152 }
1153 _ => None, // scoped_type_identifier: dropped (quirk)
1154 };
1155 if let Some(tn) = type_node {
1156 let name = self.text(tn).to_string();
1157 self.push_ref_at(class_row, &name, extends_kind, tn);
1158 }
1159 }
1160 }
1161 "field_declaration_list" | "class_heritage" => {
1162 self.extract_inheritance(child, class_row);
1163 }
1164 _ => {}
1165 }
1166 }
1167 }
1168
1169 /// extractRustImplItem — `impl Trait for Type` back-reference from the
1170 /// 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