Class: RBS::AST::Ruby::Declarations::ModuleDecl
- Inherits:
-
Base
- Object
- Base
- RBS::AST::Ruby::Declarations::ModuleDecl
show all
- Defined in:
- lib/rbs/ast/ruby/declarations.rb,
sig/ast/ruby/declarations.rbs
Instance Attribute Summary collapse
Attributes inherited from Base
#buffer
Instance Method Summary
collapse
#rbs_location
constant_as_type_name, #self?.constant_as_type_name
Constructor Details
#initialize(buffer, name, node) ⇒ ModuleDecl
Returns a new instance of ModuleDecl.
121
122
123
124
125
126
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 121
def initialize(buffer, name, node)
super(buffer)
@module_name = name
@node = node
@members = []
end
|
Instance Attribute Details
#members ⇒ Array[member]
Returns the value of attribute members.
117
118
119
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 117
def members
@members
end
|
Returns the value of attribute module_name.
115
116
117
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 115
def module_name
@module_name
end
|
#node ⇒ Prism::ModuleNode
Returns the value of attribute node.
119
120
121
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 119
def node
@node
end
|
Instance Method Details
#each_decl ⇒ void
#each_decl ⇒ Enumerator[t]
128
129
130
131
132
133
134
135
136
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 128
def each_decl(&block)
return enum_for(:each_decl) unless block
@members.each do |member|
if member.is_a?(Base)
yield member
end
end
end
|
152
153
154
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 152
def location
rbs_location(node.location)
end
|
#name_location ⇒ Location
156
157
158
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 156
def name_location
rbs_location(node.constant_path.location)
end
|
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 140
def self_types
members.filter_map do |member|
if member.is_a?(Members::ModuleSelfMember)
AST::Declarations::Module::Self.new(
name: member.name,
args: member.args,
location: member.location
)
end
end
end
|
#type_fingerprint ⇒ Object
160
161
162
163
164
165
166
167
168
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 160
def type_fingerprint
result = []
result << "decls/module"
result << module_name.to_s
result << members.map { _1.type_fingerprint}
result
end
|
138
|
# File 'lib/rbs/ast/ruby/declarations.rb', line 138
def type_params = []
|