Class: Spoom::LSP::Location

Inherits:
Object
  • Object
show all
Includes:
PrintableSymbol
Defined in:
lib/spoom/sorbet/lsp/structures.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri:, range:) ⇒ Location

: (uri: String, range: LSP::Range) -> void



140
141
142
143
# File 'lib/spoom/sorbet/lsp/structures.rb', line 140

def initialize(uri:, range:)
  @uri = uri
  @range = range
end

Instance Attribute Details

#range ⇒ Object (readonly)

: LSP::Range



137
138
139
# File 'lib/spoom/sorbet/lsp/structures.rb', line 137

def range
  @range
end

#uri ⇒ Object (readonly)

: String



134
135
136
# File 'lib/spoom/sorbet/lsp/structures.rb', line 134

def uri
  @uri
end

Class Method Details

.from_json(json) ⇒ Object

: (Hash[untyped, untyped] json) -> Location



147
148
149
150
151
152
# File 'lib/spoom/sorbet/lsp/structures.rb', line 147

def from_json(json)
  Location.new(
    uri: json["uri"],
    range: Range.from_json(json["range"]),
  )
end

Instance Method Details

#accept_printer(printer) ⇒ Object

: (SymbolPrinter printer) -> void



157
158
159
160
# File 'lib/spoom/sorbet/lsp/structures.rb', line 157

def accept_printer(printer)
  printer.print_colored("#{printer.clean_uri(uri)}:", Color::LIGHT_BLACK)
  printer.print_object(range)
end

#to_s ⇒ Object

: -> String



163
164
165
# File 'lib/spoom/sorbet/lsp/structures.rb', line 163

def to_s
  "#{uri}:#{range}"
end