handle_text_document.cpp 913 B

12345678910111213141516171819202122232425
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/language_server/handle.h"
  5. namespace Carbon::LanguageServer {
  6. auto HandleDidOpenTextDocument(
  7. Context& context, const clang::clangd::DidOpenTextDocumentParams& params)
  8. -> void {
  9. context.files().Update(params.textDocument.uri.file(),
  10. params.textDocument.text);
  11. }
  12. auto HandleDidChangeTextDocument(
  13. Context& context, const clang::clangd::DidChangeTextDocumentParams& params)
  14. -> void {
  15. // Full text is sent if full sync is specified in capabilities.
  16. CARBON_CHECK(params.contentChanges.size() == 1);
  17. context.files().Update(params.textDocument.uri.file(),
  18. params.contentChanges[0].text);
  19. }
  20. } // namespace Carbon::LanguageServer