Class: Steep::Index::RBSIndex
Defined Under Namespace
Classes: Builder, ConstantEntry, GlobalEntry, MethodEntry, TypeEntry
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#add_constant_declaration(const_name, decl) ⇒ Object
-
#add_global_declaration(global_name, decl) ⇒ Object
-
#add_method_declaration(method_name, member) ⇒ Object
-
#add_type_declaration(type_name, declaration) ⇒ Object
-
#add_type_reference(type_name, ref) ⇒ Object
-
#each_declaration(type_name: nil, method_name: nil, const_name: nil, global_name: nil, &block) ⇒ Object
-
#each_entry(&block) ⇒ Object
-
#each_reference(type_name:, &block) ⇒ Object
-
#entry(type_name: nil, method_name: nil, const_name: nil, global_name: nil) ⇒ Object
-
#initialize ⇒ RBSIndex
constructor
A new instance of RBSIndex.
Constructor Details
Returns a new instance of RBSIndex.
142
143
144
145
146
147
|
# File 'lib/steep/index/rbs_index.rb', line 142
def initialize()
@type_index = {}
@method_index = {}
@const_index = {}
@global_index = {}
end
|
Instance Attribute Details
#const_index ⇒ Object
Returns the value of attribute const_index.
139
140
141
|
# File 'lib/steep/index/rbs_index.rb', line 139
def const_index
@const_index
end
|
#global_index ⇒ Object
Returns the value of attribute global_index.
140
141
142
|
# File 'lib/steep/index/rbs_index.rb', line 140
def global_index
@global_index
end
|
#method_index ⇒ Object
Returns the value of attribute method_index.
138
139
140
|
# File 'lib/steep/index/rbs_index.rb', line 138
def method_index
@method_index
end
|
#type_index ⇒ Object
Returns the value of attribute type_index.
137
138
139
|
# File 'lib/steep/index/rbs_index.rb', line 137
def type_index
@type_index
end
|
Instance Method Details
#add_constant_declaration(const_name, decl) ⇒ Object
183
184
185
|
# File 'lib/steep/index/rbs_index.rb', line 183
def add_constant_declaration(const_name, decl)
entry(const_name: const_name).add_declaration(decl)
end
|
#add_global_declaration(global_name, decl) ⇒ Object
187
188
189
|
# File 'lib/steep/index/rbs_index.rb', line 187
def add_global_declaration(global_name, decl)
entry(global_name: global_name).add_declaration(decl)
end
|
#add_method_declaration(method_name, member) ⇒ Object
179
180
181
|
# File 'lib/steep/index/rbs_index.rb', line 179
def add_method_declaration(method_name, member)
entry(method_name: method_name).add_declaration(member)
end
|
#add_type_declaration(type_name, declaration) ⇒ Object
175
176
177
|
# File 'lib/steep/index/rbs_index.rb', line 175
def add_type_declaration(type_name, declaration)
entry(type_name: type_name).add_declaration(declaration)
end
|
#add_type_reference(type_name, ref) ⇒ Object
200
201
202
|
# File 'lib/steep/index/rbs_index.rb', line 200
def add_type_reference(type_name, ref)
entry(type_name: type_name).add_reference(ref)
end
|
#each_declaration(type_name: nil, method_name: nil, const_name: nil, global_name: nil, &block) ⇒ Object
191
192
193
194
195
196
197
198
|
# File 'lib/steep/index/rbs_index.rb', line 191
def each_declaration(type_name: nil, method_name: nil, const_name: nil, global_name: nil, &block)
if block
entry = __skip__ = entry(type_name: type_name, method_name: method_name, const_name: const_name, global_name: global_name)
entry.declarations.each(&block)
else
enum_for(:each_declaration, type_name: type_name, method_name: method_name, const_name: const_name, global_name: global_name)
end
end
|
#each_entry(&block) ⇒ Object
164
165
166
167
168
169
170
171
172
173
|
# File 'lib/steep/index/rbs_index.rb', line 164
def each_entry(&block)
if block
type_index.each_value(&block)
method_index.each_value(&block)
const_index.each_value(&block)
global_index.each_value(&block)
else
enum_for(:each_entry)
end
end
|
#each_reference(type_name:, &block) ⇒ Object
204
205
206
207
208
209
210
211
212
213
|
# File 'lib/steep/index/rbs_index.rb', line 204
def each_reference(type_name:, &block)
if block
case
when type_name
entry(type_name: type_name).references.each(&block)
end
else
enum_for(:each_reference, type_name: type_name)
end
end
|
#entry(type_name: nil, method_name: nil, const_name: nil, global_name: nil) ⇒ Object
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/steep/index/rbs_index.rb', line 149
def entry(type_name: nil, method_name: nil, const_name: nil, global_name: nil)
case
when type_name
type_index[type_name] ||= TypeEntry.new(type_name: type_name)
when method_name
method_index[method_name] ||= MethodEntry.new(method_name: method_name)
when const_name
const_index[const_name] ||= ConstantEntry.new(const_name: const_name)
when global_name
global_index[global_name] ||= GlobalEntry.new(global_name: global_name)
else
raise
end
end
|