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

Method extract_variable

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

Source from the content-addressed store, hash-verified

1072 }
1073
1074 fn extract_variable(&mut self, node: Node<'t>) {
1075 // extractVariable's generic fallback: direct identifier /
1076 // variable_declarator children only — C# nests declarators inside
1077 // variable_declaration, so this NEVER fires (`var x = F();` at top
1078 // level produces no node, no calls ref, no instantiates — preserve).
1079 let kind: &'static str = if self.is_const(node) { "constant" } else { "variable" };
1080 let docstring = preceding_docstring(node, self.src);
1081 for i in 0..node.named_child_count() {
1082 let Some(child) = node.named_child(i) else { continue };
1083 let name = match child.kind() {
1084 "identifier" => self.text(child).to_string(),
1085 "variable_declarator" => self.extract_name(child),
1086 _ => continue,
1087 };
1088 if name.is_empty() || name == "<anonymous>" {
1089 continue;
1090 }
1091 self.create_node(
1092 kind,
1093 &name,
1094 child,
1095 Extra { docstring: docstring.clone(), ..Extra::default() },
1096 );
1097 }
1098 }
1099
1100 /// extractImport via csharpExtractor.extractImport: moduleName = first
1101 /// qualified_name child's text, else first identifier's — with the alias

Callers 1

visit_nodeMethod · 0.45

Calls 5

preceding_docstringFunction · 0.85
textMethod · 0.65
is_constMethod · 0.45
extract_nameMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected