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

Method extract_import

codegraph-kernel/src/tsjs/extractors.rs:947–969  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

945 // --- extractImport + binding refs ---------------------------------------------------
946
947 pub(super) fn extract_import(&mut self, node: Node<'t>) {
948 let import_text = self.text(node).trim().to_string();
949 // typescriptExtractor.extractImport: the `source` field, quotes stripped
950 // globally. A missing/empty module means the hook declined — no node.
951 let Some(source_field) = node.child_by_field_name("source") else { return };
952 let module_name: String = self
953 .text(source_field)
954 .chars()
955 .filter(|c| *c != '\'' && *c != '"')
956 .collect();
957 if module_name.is_empty() {
958 return;
959 }
960 self.create_node(
961 "import",
962 &module_name,
963 node,
964 Extra { signature: Some(import_text), ..Extra::default() },
965 );
966 let parent = self.top_row();
967 self.push_ref(parent, &module_name.clone(), edge_kind_index("imports").unwrap(), node);
968 self.emit_import_binding_refs(node, parent);
969 }
970
971 fn emit_import_binding_refs(&mut self, node: Node<'t>, from_row: u32) {
972 let clause = (0..node.named_child_count())

Callers 1

visit_nodeMethod · 0.45

Calls 8

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
collectMethod · 0.45
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_refMethod · 0.45

Tested by

no test coverage detected