Class: TypeProf::LSP::Message::TextDocument::Definition

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

Overview

textDocument/declaration request

Constant Summary collapse

METHOD =

request

"textDocument/definition"

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



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/typeprof/lsp/messages.rb', line 176

def run
  @params => {
    textDocument: { uri: },
    position: pos,
  }
  text = @server.open_texts[uri]
  unless text
    respond(nil)
    return
  end
  defs = @server.core.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