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

Method extract_variable

codegraph-kernel/src/java.rs:813–832  ·  view source on GitHub ↗

extractVariable's generic fallback (top-level locals — rare in Java).

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

Source from the content-addressed store, hash-verified

811
812 /// extractVariable's generic fallback (top-level locals — rare in Java).
813 fn extract_variable(&mut self, node: Node<'t>) {
814 let kind: &'static str = if self.is_const(node) { "constant" } else { "variable" };
815 let docstring = preceding_docstring(node, self.src);
816 for child in node.named_children(&mut node.walk()) {
817 let name = match child.kind() {
818 "identifier" => self.text(child).to_string(),
819 "variable_declarator" => self.extract_name(child),
820 _ => continue,
821 };
822 if name.is_empty() || name == "<anonymous>" {
823 continue;
824 }
825 self.create_node(
826 kind,
827 &name,
828 child,
829 Extra { docstring: docstring.clone(), ..Extra::default() },
830 );
831 }
832 }
833
834 fn extract_import(&mut self, node: Node<'t>) {
835 let import_text = self.text(node).trim().to_string();

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