Class: Solargraph::Pin::Namespace
Instance Attribute Summary collapse
Attributes inherited from Base
#code_object, #location, #name, #source
Attributes included from Common
#closure, #context, #location
Instance Method Summary
collapse
Methods inherited from Closure
#context, #generics, #generics_as_rbs
Methods inherited from Base
#==, #comments, #deprecated?, #directives, #docstring, #erase_generics, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #probe, #probed?, #proxied?, #proxy, #realize, #resolve_generics, #resolve_generics_from_context, #to_s, #transform_types, #try_merge!, #variable?
#documentation, normalize_indentation, strip_html_comments
#completion_item, #deprecated?, #detail, #link_documentation, #probed?, #proxied?, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#comments, #name
Constructor Details
#initialize(type: :class, visibility: :public, gates: [''], **splat) ⇒ Namespace
Returns a new instance of Namespace.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/solargraph/pin/namespace.rb', line 17
def initialize type: :class, visibility: :public, gates: [''], **splat
super(**splat)
@type = type
@visibility = visibility
if name.start_with?('::')
@name = name[2..-1]
@closure = Solargraph::Pin::ROOT_PIN
end
@open_gates = gates
if @name.include?('::')
parts = @name.split('::')
@name = parts.pop
closure_name = if [Solargraph::Pin::ROOT_PIN, nil].include?(closure)
''
else
closure.full_context.namespace + '::'
end
closure_name += parts.join('::')
@closure = Pin::Namespace.new(name: closure_name, gates: [parts.join('::')])
@context = nil
end
end
|
Instance Attribute Details
#type ⇒ ::Symbol
Returns :class or :module.
12
13
14
|
# File 'lib/solargraph/pin/namespace.rb', line 12
def type
@type
end
|
#visibility ⇒ ::Symbol
Returns :public or :private.
9
10
11
|
# File 'lib/solargraph/pin/namespace.rb', line 9
def visibility
@visibility
end
|
Instance Method Details
#binder ⇒ Object
63
64
65
|
# File 'lib/solargraph/pin/namespace.rb', line 63
def binder
full_context
end
|
#completion_item_kind ⇒ Object
#desc ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/solargraph/pin/namespace.rb', line 47
def desc
if name.nil?
'(top-level)'
else
to_rbs
end
end
|
#domains ⇒ Array<String>
90
91
92
|
# File 'lib/solargraph/pin/namespace.rb', line 90
def domains
@domains ||= []
end
|
#full_context ⇒ Object
59
60
61
|
# File 'lib/solargraph/pin/namespace.rb', line 59
def full_context
@full_context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
end
|
#gates ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/solargraph/pin/namespace.rb', line 98
def gates
@gates ||= if path.empty?
@open_gates
else
[path] + @open_gates
end
end
|
#namespace ⇒ Object
55
56
57
|
# File 'lib/solargraph/pin/namespace.rb', line 55
def namespace
context.namespace
end
|
#path ⇒ String
81
82
83
|
# File 'lib/solargraph/pin/namespace.rb', line 81
def path
@path ||= (namespace.empty? ? '' : "#{namespace}::") + name
end
|
#return_type ⇒ Object
85
86
87
|
# File 'lib/solargraph/pin/namespace.rb', line 85
def return_type
@return_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
end
|
#scope ⇒ Object
67
68
69
|
# File 'lib/solargraph/pin/namespace.rb', line 67
def scope
context.scope
end
|
#to_rbs ⇒ Object
43
44
45
|
# File 'lib/solargraph/pin/namespace.rb', line 43
def to_rbs
"#{@type.to_s} #{generics_as_rbs}#{return_type.to_rbs}"
end
|
#typify(api_map) ⇒ Object
94
95
96
|
# File 'lib/solargraph/pin/namespace.rb', line 94
def typify api_map
return_type
end
|