Class: TypeProf::LSP::Message::TextDocument::Completion

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

Overview

textDocument/diagnostic request workspace/diagnostic request

workspace/diagnostic/refresh request

Constant Summary collapse

METHOD =

request

"textDocument/completion"

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



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/typeprof/lsp/messages.rb', line 317

def run
  @params => {
    textDocument: { uri: },
    position: pos,
  }
  #trigger_kind = @params.key?(:context) ? @params[:context][:triggerKind] : 1 # Invoked
  text = @server.open_texts[uri]
  unless text
    respond(nil)
    return
  end
  items = []
  sort = "aaaa"
  text.modify_for_completion(text, pos) do |string, trigger, pos|
    @server.update_file(text.path, string)
    pos = TypeProf::CodePosition.from_lsp(pos)
    @server.completion(text.path, trigger, pos) do |mid, hint|
      items << {
        label: mid,
        kind: 2, # Method
        sortText: sort,
        detail: hint,
      }
      sort = sort.succ
    end
  end
  respond(
    isIncomplete: false,
    items: items,
  )
  @server.update_file(text.path, text.string)
end