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

Method extract_import

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

1092 /// quirks (alias-to-qualified keeps generic args on the TARGET text;
1093 /// alias-to-identifier captures the ALIAS name) preserved verbatim.
1094 fn extract_import(&mut self, node: Node<'t>) {
1095 let import_text = self.text(node).trim().to_string();
1096 let target = (0..node.named_child_count())
1097 .filter_map(|i| node.named_child(i))
1098 .find(|c| c.kind() == "qualified_name")
1099 .or_else(|| {
1100 (0..node.named_child_count())
1101 .filter_map(|i| node.named_child(i))
1102 .find(|c| c.kind() == "identifier")
1103 });
1104 let Some(target) = target else { return }; // hook declined → no node, no ref
1105 let module_name = self.text(target).to_string();
1106 if module_name.is_empty() {
1107 return;
1108 }
1109 self.create_node(
1110 "import",
1111 &module_name,
1112 node,
1113 Extra { signature: Some(import_text), ..Extra::default() },
1114 );
1115 // One generic `imports` ref from the stack top (the namespace node in
1116 // a namespaced file, else the file node). No per-binding emitter.
1117 let parent = self.top_row();
1118 self.push_ref_at(parent, &module_name.clone(), edge_kind_index("imports").unwrap(), node);
1119 }
1120
1121 /// extractCall — the C# branch (tree-sitter.ts:4502) + shared tail.
1122 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