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

Method extract_variable

codegraph-kernel/src/ruby.rs:682–693  ·  view source on GitHub ↗

extractVariable — the python/ruby assignment branch (2709-2727): identifier or constant LHS mints a `variable` node (no isConst hook — `MAX = 3` is kind variable) at the ASSIGNMENT node's position, with the `= ` initializer signature.

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

Source from the content-addressed store, hash-verified

680 /// `MAX = 3` is kind variable) at the ASSIGNMENT node's position, with the
681 /// `= <first 100 utf16 units>` initializer signature.
682 fn extract_variable(&mut self, node: Node<'t>) {
683 let docstring = preceding_docstring(node, self.src);
684 let left = node.child_by_field_name("left").or_else(|| node.named_child(0));
685 let right = node.child_by_field_name("right").or_else(|| node.named_child(1));
686 let Some(left) = left else { return };
687 if !matches!(left.kind(), "identifier" | "constant") {
688 return;
689 }
690 let name = self.text(left).to_string();
691 let signature = right.map(|r| util::init_signature(self.text(r)));
692 self.create_node("variable", &name, node, Extra { docstring, signature, visibility: None });
693 }
694
695 /// extractImport — every non-body `call` lands here (importTypes:['call']).
696 /// Hook (languages/ruby.ts:123): FIRST identifier named child must read

Callers 1

visit_nodeMethod · 0.45

Calls 4

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

Tested by

no test coverage detected