Class: TypeProf::LSP::Message::TextDocument::Rename

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

Overview

textDocument/prepareRename request

Constant Summary collapse

METHOD =

request

"textDocument/rename"

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



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/typeprof/lsp/messages.rb', line 346

def run
  @params => {
    textDocument: { uri: },
    position: pos,
    newName:,
  }
  text = @server.open_texts[uri]
  unless text
    respond(nil)
    return
  end
  renames = @server.core.rename(text.path, TypeProf::CodePosition.from_lsp(pos))
  if renames
    changes = {}
    renames.each do |path, cr|
      (changes[@server.path_to_uri(path)] ||= []) << {
        range: cr.to_lsp,
        newText: newName,
      }
    end
    respond({
      changes:,
    })
  else
    respond(nil)
  end
end