Class: TypeProf::LSP::Message::TextDocument::References

Inherits:
TypeProf::LSP::Message show all
Defined in:
lib/typeprof/lsp/messages.rb

Constant Summary collapse

METHOD =

request

"textDocument/references"

Constants inherited from TypeProf::LSP::Message

Classes, TypeProf::LSP::Message::Table

Instance Method Summary collapse

Methods inherited from TypeProf::LSP::Message

build_table, find, inherited, #initialize, #log, #notify, #respond, #respond_error

Constructor Details

This class inherits a constructor from TypeProf::LSP::Message

Instance Method Details

#runObject



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/typeprof/lsp/messages.rb', line 228

def run
  @params => {
    textDocument: { uri: },
    position: pos,
  }
  text = @server.open_texts[uri]
  unless text
    respond(nil)
    return
  end
  callsites = @server.core.references(text.path, TypeProf::CodePosition.from_lsp(pos))
  if callsites
    respond(callsites.map do |path, code_range|
      {
        uri: @server.path_to_uri(path),
        range: code_range.to_lsp,
      }
    end)
  else
    respond(nil)
  end
end