Module: Requests::TextDocument::DidSave

Extended by:
DidSave
Included in:
DidSave
Defined in:
lib/holistic/language_server/requests/text_document/did_save.rb

Instance Method Summary collapse

Instance Method Details

#call(request) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/holistic/language_server/requests/text_document/did_save.rb', line 7

def call(request)
  file_path = Format::FileUri.extract_path(request.param("textDocument", "uri"))
  unsaved_document = request.application.unsaved_documents.find(file_path)

  if unsaved_document.nil?
    return request.respond_with_error(
      code: Protocol::REQUEST_FAILED_ERROR_CODE,
      description: "could not find document #{file_path} in the unsaved documents list"
    )
  end

  unsaved_document.mark_as_saved!

  ::Holistic::Ruby::Parser::LiveEditing::ProcessFileChanged.call(
    application: request.application,
    file_path: unsaved_document.path,
    content: unsaved_document.content
  )

  request.respond_with(nil)
end