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

Method extract_rust_impl_item

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

1064 /// the type's node, named by the trait's full text (scoped path / generic
1065 /// args kept), at the trait node's position.
1066 fn extract_rust_impl_item(&mut self, node: Node<'t>) {
1067 let Some(trait_node) = node.child_by_field_name("trait") else {
1068 return;
1069 };
1070 let trait_name = self.text(trait_node).to_string();
1071 let Some(type_name) = self.impl_type_name(node.child_by_field_name("type")) else {
1072 return;
1073 };
1074
1075 let target_row = self
1076 .nodes_meta
1077 .iter()
1078 .position(|m| m.name == type_name && matches!(m.kind, "struct" | "union" | "enum" | "class"))
1079 .map(|i| i as u32);
1080 if let Some(target_row) = target_row {
1081 self.push_ref_at(target_row, &trait_name, edge_kind_index("implements").unwrap(), trait_node);
1082 }
1083 }
1084
1085 /// extractTypeAnnotations — parameters + return_type subtrees, one
1086 /// `references` ref per type_identifier leaf not in BUILTIN_TYPES. The

Callers 1

visit_nodeMethod · 0.80

Calls 6

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

Tested by

no test coverage detected