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

Method extract_import

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

Source from the content-addressed store, hash-verified

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

Callers 1

visitMethod · 0.45

Calls 4

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

Tested by

no test coverage detected