Module: SimpleCov::Formatter::AIFormatter::ASTResolver::ReceiverResolver
- Extended by:
- T::Sig
- Defined in:
- lib/simplecov-ai/ast_resolver/receiver_resolver.rb
Overview
Resolves the receiver expressions that name scopes: constant paths (Foo::Bar), the
object a class << receiver singleton class opens on, and the target of a
def receiver.method singleton definition.
Constant Summary collapse
- NAMESPACE_SEPARATOR =
Separator used to denote namespace nesting (e.g., Module::Class)
T.let('::', String)
Class Method Summary collapse
- .const_name(node) ⇒ Object
- .singleton_class_name(receiver) ⇒ Object
- .singleton_method_receiver(receiver, context) ⇒ Object
Class Method Details
.const_name(node) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/simplecov-ai/ast_resolver/receiver_resolver.rb', line 23 def self.const_name(node) return '' unless node && node.type == :const scope = const_name(NodeChildren.node_at(node, 0)) name = NodeChildren.symbol_at(node, 1).to_s scope.empty? ? name : "#{scope}#{NAMESPACE_SEPARATOR}#{name}" end |
.singleton_class_name(receiver) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/simplecov-ai/ast_resolver/receiver_resolver.rb', line 38 def self.singleton_class_name(receiver) case receiver.type when :lvar, :ivar then NodeChildren.variable_name(receiver).to_s when :const then const_name(receiver) end end |
.singleton_method_receiver(receiver, context) ⇒ Object
53 54 55 56 |
# File 'lib/simplecov-ai/ast_resolver/receiver_resolver.rb', line 53 def self.singleton_method_receiver(receiver, context) const = const_name(receiver) const.empty? ? context : const end |