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

Method extract_variable

codegraph-kernel/src/python.rs:466–478  ·  view source on GitHub ↗

extractVariable's python branch: `left = right` at module scope.

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

Source from the content-addressed store, hash-verified

464
465 /// extractVariable's python branch: `left = right` at module scope.
466 fn extract_variable(&mut self, node: Node<'t>) {
467 let docstring = preceding_docstring(node, self.src);
468 let left = node.child_by_field_name("left").or_else(|| node.named_child(0));
469 let right = node.child_by_field_name("right").or_else(|| node.named_child(1));
470 let Some(left) = left else { return };
471 if !matches!(left.kind(), "identifier" | "constant") {
472 return;
473 }
474 let name = self.text(left).to_string();
475 let signature = right.map(|r| util::init_signature(self.text(r)));
476 // No isConst hook ⇒ always `variable` (UPPER_CASE constants included).
477 self.create_node("variable", &name, node, Extra { docstring, signature, ..Extra::default() });
478 }
479
480 fn extract_import(&mut self, node: Node<'t>) {
481 let import_text = self.text(node).trim().to_string();

Callers 1

visit_nodeMethod · 0.45

Calls 4

preceding_docstringFunction · 0.85
init_signatureFunction · 0.85
textMethod · 0.45
create_nodeMethod · 0.45

Tested by

no test coverage detected