mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-22 11:32:40 +00:00
We currently provide UTF-8 positions, since our source representation is UTF-8 and we use byte offsets as column numbers, but the LSP protocol default is UTF-16 column positions. Negotiate UTF-8 positions where possible; this is supported by essentially every LSP client other than VS Code. In the case where we select a UTF-16 position, we continue to not do any actual conversions, so our column offsets in such cases will continue to be wrong on non-ASCII source files in VS Code. Assisted by: Claude Code
61 lines
2.1 KiB
C++
61 lines
2.1 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_LANGUAGE_SERVER_HANDLE_H_
|
|
#define CARBON_TOOLCHAIN_LANGUAGE_SERVER_HANDLE_H_
|
|
|
|
#include "clang-tools-extra/clangd/Protocol.h"
|
|
#include "toolchain/language_server/context.h"
|
|
|
|
namespace Carbon::LanguageServer {
|
|
|
|
// Stores the content of newly-opened documents.
|
|
auto HandleDidChangeTextDocument(
|
|
Context& context, const clang::clangd::DidChangeTextDocumentParams& params)
|
|
-> void;
|
|
|
|
// Closes a document.
|
|
auto HandleDidCloseTextDocument(
|
|
Context& context, const clang::clangd::DidCloseTextDocumentParams& params)
|
|
-> void;
|
|
|
|
// Acknowledges that a document was saved.
|
|
auto HandleDidSaveTextDocument(
|
|
Context& context, const clang::clangd::DidSaveTextDocumentParams& params)
|
|
-> void;
|
|
|
|
// Updates the content of already-open documents.
|
|
auto HandleDidOpenTextDocument(
|
|
Context& context, const clang::clangd::DidOpenTextDocumentParams& params)
|
|
-> void;
|
|
|
|
// Provides information about document symbols.
|
|
auto HandleDocumentSymbol(
|
|
Context& context, const clang::clangd::DocumentSymbolParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::DocumentSymbol>>)->void>
|
|
on_done) -> void;
|
|
|
|
// Tells the client what features are supported, and negotiates the position
|
|
// encoding.
|
|
auto HandleInitialize(
|
|
Context& context, const clang::clangd::InitializeParams& params,
|
|
llvm::function_ref<auto(llvm::Expected<llvm::json::Object>)->void> on_done)
|
|
-> void;
|
|
|
|
// Acknowledges that the client finished initializing.
|
|
auto HandleInitialized(Context& context, const clang::clangd::NoParams& params)
|
|
-> void;
|
|
|
|
// Prepares LSP for shutdown.
|
|
auto HandleShutdown(
|
|
Context& /*context*/,
|
|
const clang::clangd::NoParams& /*client_capabilities*/,
|
|
llvm::function_ref<auto(llvm::Expected<std::nullptr_t>)->void> on_done)
|
|
-> void;
|
|
|
|
} // namespace Carbon::LanguageServer
|
|
|
|
#endif // CARBON_TOOLCHAIN_LANGUAGE_SERVER_HANDLE_H_
|