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

Method extract_rust_impl_item

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

extractRustImplItem — `impl Trait for Type` back-reference from the grammar's `trait` / `type` fields (#1588; an inherent impl has no `trait` field and emits nothing). Target = FIRST earlier node of kind struct/union/enum/class (never trait) named by impl_type_name; ref FROM the type's node, named by the trait's full text (scoped path / generic args kept), at the trait node's position.

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

Source from the content-addressed store, hash-verified

1192 /// the type's node, named by the trait's full text (scoped path / generic
1193 /// args kept), at the trait node's position.
1194 fn extract_rust_impl_item(&mut self, node: Node<'t>) {
1195 let Some(trait_node) = node.child_by_field_name("trait") else {
1196 return;
1197 };
1198 let trait_name = self.text(trait_node).to_string();
1199 let Some(type_name) = self.impl_type_name(node.child_by_field_name("type")) else {
1200 return;
1201 };
1202
1203 let target_row = self
1204 .nodes_meta
1205 .iter()
1206 .position(|m| m.name == type_name && matches!(m.kind, "struct" | "union" | "enum" | "class"))
1207 .map(|i| i as u32);
1208 if let Some(target_row) = target_row {
1209 self.push_ref_at(target_row, &trait_name, edge_kind_index("implements").unwrap(), trait_node);
1210 }
1211 }
1212
1213 /// extractTypeAnnotations — parameters + return_type subtrees, one
1214 /// `references` ref per type_identifier leaf not in BUILTIN_TYPES. The

Callers 1

visit_nodeMethod · 0.80

Calls 7

edge_kind_indexFunction · 0.85
impl_type_nameMethod · 0.80
mapMethod · 0.80
positionMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
push_ref_atMethod · 0.45

Tested by

no test coverage detected