Class: Yoda::Model::Environment::NamespaceMembers
- Inherits:
-
Object
- Object
- Yoda::Model::Environment::NamespaceMembers
- Defined in:
- lib/yoda/model/environment/namespace_members.rb
Instance Attribute Summary collapse
- #accessor ⇒ AccessorInterface readonly
- #environment ⇒ Environment readonly
Instance Method Summary collapse
-
#initialize(accessor:, environment:) ⇒ NamespaceMembers
constructor
A new instance of NamespaceMembers.
- #select_constant_paths(name) ⇒ Array<Symbol>
- #select_constant_type(name) ⇒ RBS::Types::t
- #select_method(name, visibility:) ⇒ Enumerator<FunctionSignatures::Base>
Constructor Details
#initialize(accessor:, environment:) ⇒ NamespaceMembers
Returns a new instance of NamespaceMembers.
15 16 17 18 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 15 def initialize(accessor:, environment:) @accessor = accessor @environment = environment end |
Instance Attribute Details
#accessor ⇒ AccessorInterface (readonly)
8 9 10 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 8 def accessor @accessor end |
#environment ⇒ Environment (readonly)
11 12 13 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 11 def environment @environment end |
Instance Method Details
#select_constant_paths(name) ⇒ Array<Symbol>
44 45 46 47 48 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 44 def select_constant_paths(name, **) # TODO: Search RBS stored_consts = stored_constant_members&.select(name) || [] stored_consts.map(&:path) end |
#select_constant_type(name) ⇒ RBS::Types::t
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 52 def select_constant_type(name, **) paths = select_constant_paths(name) types = paths.flat_map do |path| name = accessor.environment.resolve_rbs_type_name(path) name && RBS::Types::ClassSingleton.new( name: name, location: nil, ) end.compact if types.empty? RBS::Types::Bases::Any.new(location: nil) else RBS::Types::Union.new(types: types, location: nil) end end |
#select_method(name, visibility:) ⇒ Enumerator<FunctionSignatures::Base>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yoda/model/environment/namespace_members.rb', line 23 def select_method(name, visibility:) rbs_method_signatures = begin method_defs = filter_rbs_methods(name, visibility: visibility) method_defs.flat_map do |method_def| method_def.defs.map do |type_def| FunctionSignatures::RbsMethod.new( rbs_definition: accessor.rbs_definition, rbs_method_definition: method_def, rbs_method_typedef: type_def, ) end end end stored_signatures = stored_method_members&.select_signature(name, visibility: visibility) || [] (rbs_method_signatures + stored_signatures).map { |sig| sig.wrap(environment) } end |