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

Method extract_import

codegraph-kernel/src/scala.rs:821–853  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

819 // --- extractImport (:3170-3236) ---------------------------------------
820
821 fn extract_import(&mut self, node: Node<'t>) {
822 stack_guard!();
823 let import_text = self.text(node).trim();
824 // extractImport hook (scala.ts:200-211): `path` field is FIRST-MATCH-
825 // WINS → the FIRST dotted segment names the import.
826 let module = if let Some(path) = node.child_by_field_name("path") {
827 Some(self.text(path))
828 } else {
829 let mut cursor = node.walk();
830 let mut found = None;
831 for c in node.named_children(&mut cursor) {
832 if c.kind() == "identifier" || c.kind() == "stable_identifier" {
833 found = Some(self.text(c));
834 break;
835 }
836 }
837 found
838 };
839 let Some(module) = module else { return };
840 let module = module.to_string();
841 let signature = import_text.to_string();
842 let created = self.create_node(
843 "import",
844 &module,
845 node,
846 Extra { signature: Some(signature), ..Default::default() },
847 );
848 // Generic imports ref (:3183-3194) — hook sets no handledRefs.
849 if created.is_some() && !module.is_empty() && !self.stack.is_empty() {
850 let parent_row = self.top_row();
851 self.push_ref_at(parent_row, &module, "imports", node);
852 }
853 }
854
855 // --- extractCall (:3684) ----------------------------------------------
856

Callers 1

visitMethod · 0.45

Calls 4

textMethod · 0.65
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected