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

Method extract_variable

codegraph-kernel/src/java.rs:831–851  ·  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

829
830 /// extractVariable's generic fallback (top-level locals — rare in Java).
831 fn extract_variable(&mut self, node: Node<'t>) {
832 let kind: &'static str = if self.is_const(node) { "constant" } else { "variable" };
833 let docstring = preceding_docstring(node, self.src);
834 for i in 0..node.named_child_count() {
835 let Some(child) = node.named_child(i) else { continue };
836 let name = match child.kind() {
837 "identifier" => self.text(child).to_string(),
838 "variable_declarator" => self.extract_name(child),
839 _ => continue,
840 };
841 if name.is_empty() || name == "<anonymous>" {
842 continue;
843 }
844 self.create_node(
845 kind,
846 &name,
847 child,
848 Extra { docstring: docstring.clone(), ..Extra::default() },
849 );
850 }
851 }
852
853 fn extract_import(&mut self, node: Node<'t>) {
854 let import_text = self.text(node).trim().to_string();

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