Class: Solargraph::Pin::Closure
- Inherits:
-
Base
- Object
- Base
- Solargraph::Pin::Closure
show all
- Defined in:
- lib/solargraph/pin/closure.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#code_object, #location, #name, #path, #return_type, #source, #type_location
Attributes included from Common
#closure, #location
Instance Method Summary
collapse
Methods inherited from Base
#==, #all_rooted?, #best_location, #comments, #completion_item_kind, #deprecated?, #desc, #directives, #docstring, #erase_generics, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #presence_certain?, #probe, #probed?, #proxied?, #proxy, #realize, #resolve_generics, #resolve_generics_from_context, #symbol_kind, #to_s, #transform_types, #try_merge!, #type_desc, #typify, #variable?
#documentation, normalize_indentation, strip_html_comments
#completion_item, #completion_item_kind, #deprecated?, #detail, #link_documentation, #probed?, #proxied?, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#comments, #name, #namespace, #path, #return_type
Constructor Details
#initialize(scope: :class, generics: nil, **splat) ⇒ Closure
11
12
13
14
15
|
# File 'lib/solargraph/pin/closure.rb', line 11
def initialize scope: :class, generics: nil, **splat
super(**splat)
@scope = scope
@generics = generics
end
|
Instance Attribute Details
#scope ⇒ ::Symbol
7
8
9
|
# File 'lib/solargraph/pin/closure.rb', line 7
def scope
@scope
end
|
Instance Method Details
#binder ⇒ Object
28
29
30
|
# File 'lib/solargraph/pin/closure.rb', line 28
def binder
@binder || context
end
|
#context ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/solargraph/pin/closure.rb', line 17
def context
@context ||= begin
result = super
if scope == :instance
result.reduce_class_type
else
result
end
end
end
|
#gates ⇒ ::Array<String>
33
34
35
36
37
|
# File 'lib/solargraph/pin/closure.rb', line 33
def gates
closure ? closure.gates : ['']
end
|
#generics ⇒ ::Array<String>
40
41
42
|
# File 'lib/solargraph/pin/closure.rb', line 40
def generics
@generics ||= docstring.tags(:generic).map(&:name)
end
|
#rbs_generics ⇒ String
50
51
52
53
54
|
# File 'lib/solargraph/pin/closure.rb', line 50
def rbs_generics
return '' if generics.empty?
'[' + generics.map { |gen| gen.to_s }.join(', ') + '] '
end
|
#to_rbs ⇒ String
45
46
47
|
# File 'lib/solargraph/pin/closure.rb', line 45
def to_rbs
rbs_generics + return_type.to_rbs
end
|