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

Method constructed_class

codegraph-kernel/src/ruby.rs:222–232  ·  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

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

Callers 1

extract_callMethod · 0.80

Calls 2

is_constant_pathFunction · 0.85
textMethod · 0.65

Tested by

no test coverage detected