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

Method extract_variable

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

Source from the content-addressed store, hash-verified

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

Callers 1

visit_nodeMethod · 0.45

Calls 6

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

Tested by

no test coverage detected