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

Method constructed_class

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

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

Callers 1

extract_callMethod · 0.80

Calls 2

is_constant_pathFunction · 0.85
textMethod · 0.65

Tested by

no test coverage detected