Class: Solargraph::Suggestion
- Inherits:
-
Object
- Object
- Solargraph::Suggestion
- Defined in:
- lib/solargraph/suggestion.rb
Constant Summary collapse
- CLASS =
'Class'
- CONSTANT =
'Constant'
- KEYWORD =
'Keyword'
- MODULE =
'Module'
- METHOD =
'Method'
- VARIABLE =
'Variable'
- PROPERTY =
'Property'
- FIELD =
'Field'
- SNIPPET =
'Snippet'
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#code_object ⇒ Object
readonly
Returns the value of attribute code_object.
-
#detail ⇒ Object
readonly
Returns the value of attribute detail.
-
#documentation ⇒ Object
readonly
Returns the value of attribute documentation.
-
#insert ⇒ Object
readonly
Returns the value of attribute insert.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Instance Method Summary collapse
-
#initialize(label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil, location: nil, arguments: [], return_type: nil) ⇒ Suggestion
constructor
A new instance of Suggestion.
- #params ⇒ Object
- #path ⇒ Object
- #return_type ⇒ Object
- #to_json(args = {}) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil, location: nil, arguments: [], return_type: nil) ⇒ Suggestion
Returns a new instance of Suggestion.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/solargraph/suggestion.rb', line 18 def initialize label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil, location: nil, arguments: [], return_type: nil @helper = Server::Helpers.new @label = label.to_s @kind = kind @insert = insert || @label @detail = detail @code_object = code_object @documentation = documentation @location = location @arguments = arguments @return_type = return_type end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def arguments @arguments end |
#code_object ⇒ Object (readonly)
Returns the value of attribute code_object.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def code_object @code_object end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def detail @detail end |
#documentation ⇒ Object (readonly)
Returns the value of attribute documentation.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def documentation @documentation end |
#insert ⇒ Object (readonly)
Returns the value of attribute insert.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def insert @insert end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def kind @kind end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def label @label end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
16 17 18 |
# File 'lib/solargraph/suggestion.rb', line 16 def location @location end |
Instance Method Details
#params ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/solargraph/suggestion.rb', line 68 def params if @params.nil? @params = [] return @params if documentation.nil? = documentation.(:param) unless .empty? .each do |t| txt = t.name.to_s txt += " [#{t.types.join(',')}]" unless t.types.nil? or t.types.empty? txt += " #{t.text}" unless t.text.nil? or t.text.empty? @params.push txt end end end @params end |
#path ⇒ Object
31 32 33 |
# File 'lib/solargraph/suggestion.rb', line 31 def path code_object.nil? ? label : code_object.path end |
#return_type ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/solargraph/suggestion.rb', line 39 def return_type if @return_type.nil? if code_object.nil? if documentation.kind_of?(YARD::Docstring) t = documentation.tag(:return) @return_type = t.types[0] unless t.nil? or t.types.nil? end else o = code_object.tag(:overload) if o.nil? r = code_object.tag(:return) else r = o.tag(:return) end @return_type = r.types[0] unless r.nil? or r.types.nil? end end @return_type end |
#to_json(args = {}) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/solargraph/suggestion.rb', line 85 def to_json args={} obj = { label: @label, kind: @kind, insert: @insert, detail: @detail, path: path, location: (@location.nil? ? nil : @location.to_s), arguments: @arguments, params: params, return_type: return_type, documentation: @helper.html_markup_rdoc(documentation.to_s) } obj.to_json(args) end |
#to_s ⇒ Object
35 36 37 |
# File 'lib/solargraph/suggestion.rb', line 35 def to_s label end |