Class: TypeProf::LSP::Message::TextDocument::TypeDefinition

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

Constant Summary collapse

METHOD =

request

"textDocument/typeDefinition"

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



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/typeprof/lsp/messages.rb', line 202

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