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

Method extract_import

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

Source from the content-addressed store, hash-verified

836 // --- extractImport (:3170-3236) ---------------------------------------
837
838 fn extract_import(&mut self, node: Node<'t>) {
839 stack_guard!();
840 let import_text = self.text(node).trim();
841 // extractImport hook (scala.ts:200-211): `path` field is FIRST-MATCH-
842 // WINS → the FIRST dotted segment names the import.
843 let module = if let Some(path) = node.child_by_field_name("path") {
844 Some(self.text(path))
845 } else {
846 let mut cursor = node.walk();
847 let mut found = None;
848 for c in node.named_children(&mut cursor) {
849 if c.kind() == "identifier" || c.kind() == "stable_identifier" {
850 found = Some(self.text(c));
851 break;
852 }
853 }
854 found
855 };
856 let Some(module) = module else { return };
857 let module = module.to_string();
858 let signature = import_text.to_string();
859 let created = self.create_node(
860 "import",
861 &module,
862 node,
863 Extra { signature: Some(signature), ..Default::default() },
864 );
865 // Generic imports ref (:3183-3194) — hook sets no handledRefs.
866 if created.is_some() && !module.is_empty() && !self.stack.is_empty() {
867 let parent_row = self.top_row();
868 self.push_ref_at(parent_row, &module, "imports", node);
869 }
870 }
871
872 // --- extractCall (:3684) ----------------------------------------------
873

Callers 1

visitMethod · 0.45

Calls 5

walkMethod · 0.80
textMethod · 0.65
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected