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

Method extract_import

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

782 /// one generic root `imports` ref + per-binding FULL-path refs.
783 /// `use x::*;` (use_wildcard) → hook returns null → nothing at all.
784 fn extract_import(&mut self, node: Node<'t>) {
785 let use_arg = (0..node.named_child_count())
786 .filter_map(|i| node.named_child(i))
787 .find(|c| matches!(c.kind(), "scoped_use_list" | "scoped_identifier" | "use_list" | "identifier"));
788 let Some(use_arg) = use_arg else { return };
789
790 let module_name = self.root_module(use_arg);
791 let signature = self.text(node).trim().to_string();
792 self.create_node(
793 "import",
794 &module_name.clone(),
795 node,
796 Extra { signature: Some(signature), ..Extra::default() },
797 );
798 let parent = self.top_row();
799 let imports_kind = edge_kind_index("imports").unwrap();
800 if !module_name.is_empty() {
801 self.push_ref_at(parent, &module_name, imports_kind, node);
802 }
803 self.emit_use_binding_refs(node, parent);
804 }
805
806 /// getRootModule (languages/rust.ts:124).
807 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
textMethod · 0.65
unwrapMethod · 0.60
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected