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

Method extract_import

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

extractImport via the rust hook: import node named by the ROOT module + one generic root `imports` ref + per-binding FULL-path refs. `use x::*;` (use_wildcard) → hook returns null → nothing at all.

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

Source from the content-addressed store, hash-verified

675 /// one generic root `imports` ref + per-binding FULL-path refs.
676 /// `use x::*;` (use_wildcard) → hook returns null → nothing at all.
677 fn extract_import(&mut self, node: Node<'t>) {
678 let use_arg = (0..node.named_child_count())
679 .filter_map(|i| node.named_child(i))
680 .find(|c| matches!(c.kind(), "scoped_use_list" | "scoped_identifier" | "use_list" | "identifier"));
681 let Some(use_arg) = use_arg else { return };
682
683 let module_name = self.root_module(use_arg);
684 let signature = self.text(node).trim().to_string();
685 self.create_node(
686 "import",
687 &module_name.clone(),
688 node,
689 Extra { signature: Some(signature), ..Extra::default() },
690 );
691 let parent = self.top_row();
692 let imports_kind = edge_kind_index("imports").unwrap();
693 if !module_name.is_empty() {
694 self.push_ref_at(parent, &module_name, imports_kind, node);
695 }
696 self.emit_use_binding_refs(node, parent);
697 }
698
699 /// getRootModule (languages/rust.ts:124).
700 fn root_module(&self, n: Node) -> String {

Callers 1

visit_nodeMethod · 0.45

Calls 8

edge_kind_indexFunction · 0.85
root_moduleMethod · 0.80
emit_use_binding_refsMethod · 0.80
unwrapMethod · 0.60
textMethod · 0.45
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected