Class: Solargraph::Pin::Method
- Inherits:
-
Base
- Object
- Base
- Solargraph::Pin::Method
show all
- Defined in:
- lib/solargraph/pin/method.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#location, #name, #namespace
Instance Method Summary
collapse
Methods inherited from Base
#==, #comments, #deprecated?, #directives, #docstring, #filename, #infer, #macros, #maybe_directives?, #return_type, #to_s, #try_merge!, #variable?
#completion_item, #detail, #link_documentation, #reset_conversions, #resolve_completion_item, #signature_help
Constructor Details
#initialize(location, namespace, name, comments, scope, visibility, args) ⇒ Method
Returns a new instance of Method.
13
14
15
16
17
18
|
# File 'lib/solargraph/pin/method.rb', line 13
def initialize location, namespace, name, , scope, visibility, args
super(location, namespace, name, )
@scope = scope
@visibility = visibility
@parameters = args
end
|
Instance Attribute Details
#parameters ⇒ Array<String>
11
12
13
|
# File 'lib/solargraph/pin/method.rb', line 11
def parameters
@parameters
end
|
Returns :instance or :class.
5
6
7
|
# File 'lib/solargraph/pin/method.rb', line 5
def scope
@scope
end
|
#visibility ⇒ Symbol
Returns :public, :private, or :protected.
8
9
10
|
# File 'lib/solargraph/pin/method.rb', line 8
def visibility
@visibility
end
|
Instance Method Details
#completion_item_kind ⇒ Object
#context ⇒ Object
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/solargraph/pin/method.rb', line 33
def context
@context ||= begin
if scope == :class
ComplexType.parse("Class<#{namespace}>")
else
ComplexType.parse(namespace)
end
end
end
|
#documentation ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/solargraph/pin/method.rb', line 57
def documentation
if @documentation.nil?
@documentation ||= super || ''
param_tags = docstring.tags(:param)
unless param_tags.nil? or param_tags.empty?
@documentation += "\n\n" unless @documentation.empty?
@documentation += "Params:\n"
lines = []
param_tags.each do |p|
l = "* #{p.name}"
l += " [#{p.types.join(', ')}]" unless p.types.nil? or p.types.empty?
l += " #{p.text}"
lines.push l
end
@documentation += lines.join("\n")
end
end
@documentation
end
|
#nearly?(other) ⇒ Boolean
77
78
79
80
81
82
|
# File 'lib/solargraph/pin/method.rb', line 77
def nearly? other
return false unless super
parameters == other.parameters and
scope == other.scope and
visibility == other.visibility
end
|
#parameter_names ⇒ Array<String>
21
22
23
|
# File 'lib/solargraph/pin/method.rb', line 21
def parameter_names
@parameter_names ||= parameters.map{|p| p.split(/[ =:]/).first}
end
|
#path ⇒ Object
29
30
31
|
# File 'lib/solargraph/pin/method.rb', line 29
def path
@path ||= namespace + (scope == :instance ? '#' : '.') + name
end
|
#return_complex_type ⇒ Object
53
54
55
|
# File 'lib/solargraph/pin/method.rb', line 53
def return_complex_type
@return_complex_type ||= generate_complex_type
end
|