Class: TypeProf::LSP::Message::TextDocument::CodeLens

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

Constant Summary collapse

METHOD =
"textDocument/codeLens"

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



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/typeprof/lsp/messages.rb', line 275

def run
  @params => { textDocument: { uri: } }
  text = @server.open_texts[uri]
  if !text || !@server.signature_enabled
    respond(nil)
    return
  end
  ret = []
  @server.core.code_lens(text.path) do |code_range, title|
    pos = code_range.first
    ret << {
      range: TypeProf::CodeRange.new(pos, pos.right).to_lsp,
      command: {
        title: "#: " + title,
        command: "typeprof.createPrototypeRBS",
        arguments: [uri, code_range.first.lineno, code_range.first.column, title],
      },
    }
  end
  respond(ret)
end