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

Method constructed_class

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

rubyConstructedClass (tree-sitter.ts): the class a call receiver constructs, as written — `Foo` for `Foo.new(key)`, `Billing::Card` for `Billing::Card.new`, `::Foo` for `::Foo.new`; None for any other receiver, a `new` on a value (`klass.new`) among them.

(&self, receiver: Node)

Source from the content-addressed store, hash-verified

215 /// `Billing::Card.new`, `::Foo` for `::Foo.new`; None for any other
216 /// receiver, a `new` on a value (`klass.new`) among them.
217 fn constructed_class(&self, receiver: Node) -> Option<&'t str> {
218 if receiver.kind() != "call" {
219 return None;
220 }
221 let method = receiver.child_by_field_name("method")?;
222 let made = receiver.child_by_field_name("receiver")?;
223 if self.text(method) != "new" || !is_constant_path(made) {
224 return None;
225 }
226 Some(self.text(made))
227 }
228 fn line_of(&self, node: Node) -> u32 {
229 node.start_position().row as u32 + 1
230 }

Callers 1

extract_callMethod · 0.80

Calls 2

is_constant_pathFunction · 0.85
textMethod · 0.65

Tested by

no test coverage detected