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

Method extract_import

codegraph-kernel/src/csharp.rs:981–1006  ·  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

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

Callers 1

visit_nodeMethod · 0.45

Calls 6

edge_kind_indexFunction · 0.85
unwrapMethod · 0.60
textMethod · 0.45
create_nodeMethod · 0.45
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected