Class: Spoom::LSP::Hover
- Inherits:
-
Object
- Object
- Spoom::LSP::Hover
- Includes:
- PrintableSymbol
- Defined in:
- lib/spoom/sorbet/lsp/structures.rb
Instance Attribute Summary collapse
-
#contents ⇒ Object
readonly
: String.
-
#range ⇒ Object
readonly
: Range?.
Class Method Summary collapse
-
.from_json(json) ⇒ Object
: (Hash[untyped, untyped] json) -> Hover.
Instance Method Summary collapse
-
#accept_printer(printer) ⇒ Object
: (SymbolPrinter printer) -> void.
-
#initialize(contents:, range: nil) ⇒ Hover
constructor
: (contents: String, ?range: Range?) -> void.
-
#to_s ⇒ Object
: -> String.
Constructor Details
#initialize(contents:, range: nil) ⇒ Hover
: (contents: String, ?range: Range?) -> void
102 103 104 105 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 102 def initialize(contents:, range: nil) @contents = contents @range = range end |
Instance Attribute Details
#contents ⇒ Object (readonly)
: String
96 97 98 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 96 def contents @contents end |
#range ⇒ Object (readonly)
: Range?
99 100 101 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 99 def range @range end |
Class Method Details
.from_json(json) ⇒ Object
: (Hash[untyped, untyped] json) -> Hover
109 110 111 112 113 114 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 109 def from_json(json) Hover.new( contents: json["contents"]["value"], range: json["range"] ? Range.from_json(json["range"]) : nil, ) end |
Instance Method Details
#accept_printer(printer) ⇒ Object
: (SymbolPrinter printer) -> void
119 120 121 122 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 119 def accept_printer(printer) printer.print("#{contents}\n") printer.print_object(range) if range end |
#to_s ⇒ Object
: -> String
125 126 127 |
# File 'lib/spoom/sorbet/lsp/structures.rb', line 125 def to_s "#{contents} (#{range})." end |