Class: Solargraph::Suggestion
- Inherits:
-
Object
- Object
- Solargraph::Suggestion
- Defined in:
- lib/solargraph/suggestion.rb
Constant Summary collapse
- CLASS =
'Class'- 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: []) ⇒ Suggestion
constructor
A new instance of Suggestion.
- #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: []) ⇒ Suggestion
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/solargraph/suggestion.rb', line 17 def initialize label, kind: KEYWORD, insert: nil, detail: nil, documentation: nil, code_object: nil, location: nil, arguments: [] @helper = Server::Helpers.new @label = label.to_s @kind = kind @insert = insert || @label @detail = detail @code_object = code_object @documentation = @helper.html_markup_rdoc(documentation.to_s) unless documentation.nil? @location = location @arguments = arguments end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def arguments @arguments end |
#code_object ⇒ Object (readonly)
Returns the value of attribute code_object.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def code_object @code_object end |
#detail ⇒ Object (readonly)
Returns the value of attribute detail.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def detail @detail end |
#documentation ⇒ Object (readonly)
Returns the value of attribute documentation.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def documentation @documentation end |
#insert ⇒ Object (readonly)
Returns the value of attribute insert.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def insert @insert end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def kind @kind end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def label @label end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
15 16 17 |
# File 'lib/solargraph/suggestion.rb', line 15 def location @location end |
Instance Method Details
#path ⇒ Object
29 30 31 |
# File 'lib/solargraph/suggestion.rb', line 29 def path code_object.nil? ? label : code_object.path end |
#return_type ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solargraph/suggestion.rb', line 37 def return_type if code_object.nil? unless documentation.nil? match = documentation.match(/@return \[([a-z0-9:_]*)/i) return match[1] unless match.nil? end else o = code_object.tag(:overload) if o.nil? r = code_object.tag(:return) else r = o.tag(:return) end return r.types[0] unless r.nil? end nil end |
#to_json(args = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/solargraph/suggestion.rb', line 64 def to_json args={} obj = { label: @label, kind: @kind, insert: @insert, detail: @detail, path: path, location: (@location.nil? ? nil : @location.to_s), arguments: @arguments, return_type: return_type, documentation: documentation } obj.to_json(args) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/solargraph/suggestion.rb', line 33 def to_s label end |