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

Method extract_import

codegraph-kernel/src/csharp.rs:990–1015  ·  view source on GitHub ↗

extractImport via csharpExtractor.extractImport: moduleName = first qualified_name child's text, else first identifier's — with the alias quirks (alias-to-qualified keeps generic args on the TARGET text; alias-to-identifier captures the ALIAS name) preserved verbatim.

(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

988 /// quirks (alias-to-qualified keeps generic args on the TARGET text;
989 /// alias-to-identifier captures the ALIAS name) preserved verbatim.
990 fn extract_import(&mut self, node: Node<'t>) {
991 let import_text = self.text(node).trim().to_string();
992 let target = (0..node.named_child_count())
993 .filter_map(|i| node.named_child(i))
994 .find(|c| c.kind() == "qualified_name")
995 .or_else(|| {
996 (0..node.named_child_count())
997 .filter_map(|i| node.named_child(i))
998 .find(|c| c.kind() == "identifier")
999 });
1000 let Some(target) = target else { return }; // hook declined → no node, no ref
1001 let module_name = self.text(target).to_string();
1002 if module_name.is_empty() {
1003 return;
1004 }
1005 self.create_node(
1006 "import",
1007 &module_name,
1008 node,
1009 Extra { signature: Some(import_text), ..Extra::default() },
1010 );
1011 // One generic `imports` ref from the stack top (the namespace node in
1012 // a namespaced file, else the file node). No per-binding emitter.
1013 let parent = self.top_row();
1014 self.push_ref_at(parent, &module_name.clone(), edge_kind_index("imports").unwrap(), node);
1015 }
1016
1017 /// extractCall — the C# branch (tree-sitter.ts:4502) + shared tail.
1018 fn extract_call(&mut self, node: Node<'t>) {

Callers 1

visit_nodeMethod · 0.45

Calls 6

edge_kind_indexFunction · 0.85
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