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



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/typeprof/lsp/messages.rb', line 306

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.core.update_file(text.path, string)
    pos = TypeProf::CodePosition.from_lsp(pos)
    @server.core.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.core.update_file(text.path, text.string)
end