Class: Solargraph::Pin::Namespace
Instance Attribute Summary collapse
Attributes inherited from Base
#code_object, #location, #name
Attributes included from Common
#closure, #location
Instance Method Summary
collapse
Methods inherited from Closure
#context
Methods inherited from Base
#==, #comments, #deprecated?, #directives, #docstring, #filename, #identity, #infer, #inspect, #macros, #maybe_directives?, #nearly?, #probe, #probed?, #proxied?, #proxy, #realize, #to_s, #try_merge!, #variable?
#documentation
#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help, #text_documentation
Methods included from Common
#comments, #context, #name
Constructor Details
#initialize(type: :class, visibility: :public, gates: [''], **splat) ⇒ Namespace
Returns a new instance of Namespace.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/solargraph/pin/namespace.rb', line 15
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.
10
11
12
|
# File 'lib/solargraph/pin/namespace.rb', line 10
def type
@type
end
|
#visibility ⇒ ::Symbol
Returns :public or :private.
7
8
9
|
# File 'lib/solargraph/pin/namespace.rb', line 7
def visibility
@visibility
end
|
Instance Method Details
#binder ⇒ Object
49
50
51
|
# File 'lib/solargraph/pin/namespace.rb', line 49
def binder
full_context
end
|
#completion_item_kind ⇒ Object
#domains ⇒ Object
74
75
76
|
# File 'lib/solargraph/pin/namespace.rb', line 74
def domains
@domains ||= []
end
|
#full_context ⇒ Object
45
46
47
|
# File 'lib/solargraph/pin/namespace.rb', line 45
def full_context
@full_context ||= ComplexType.try_parse("#{type.to_s.capitalize}<#{path}>")
end
|
#gates ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/solargraph/pin/namespace.rb', line 82
def gates
@gates ||= if path.empty?
@open_gates
else
[path] + @open_gates
end
end
|
#namespace ⇒ Object
41
42
43
|
# File 'lib/solargraph/pin/namespace.rb', line 41
def namespace
context.namespace
end
|
#path ⇒ Object
66
67
68
|
# File 'lib/solargraph/pin/namespace.rb', line 66
def path
@path ||= (namespace.empty? ? '' : "#{namespace}::") + name
end
|
#return_type ⇒ Object
70
71
72
|
# File 'lib/solargraph/pin/namespace.rb', line 70
def return_type
@return_type ||= ComplexType.try_parse( (type == :class ? 'Class' : 'Module') + "<#{path}>" )
end
|
#scope ⇒ Object
53
54
55
|
# File 'lib/solargraph/pin/namespace.rb', line 53
def scope
context.scope
end
|
#typify(api_map) ⇒ Object
78
79
80
|
# File 'lib/solargraph/pin/namespace.rb', line 78
def typify api_map
return_type
end
|