mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 11:40:14 +01:00
Add hover cards and jump to declaration / definition / reference for the formatted SemIR that appears in check tests. This is done by adding a heuristic "parser" for SemIR to the language server. The cross-references are strictly best-effort, since this is just a tool for Carbon developers, not a user-facing facility. A couple of other changes made along the way: * file_test tests with an AUTOUPDATE-SPLIT no longer look for CHECK: lines outside that split. This was motivated by the tests for this new facility including CHECK: lines as part of the test input. * An agent skill for working on the language server, tracking some things that cost Claude time when working on this. Assisted-by: Claude via Antigravity
109 lines
4.0 KiB
C++
109 lines
4.0 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 {
|
|
|
|
// Locates where the entity named at a position was declared.
|
|
auto HandleDeclaration(
|
|
Context& context, const clang::clangd::TextDocumentPositionParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::Location>>)->void>
|
|
on_done) -> void;
|
|
|
|
// Locates the entity named at a position.
|
|
auto HandleDefinition(
|
|
Context& context, const clang::clangd::TextDocumentPositionParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::Location>>)->void>
|
|
on_done) -> void;
|
|
|
|
// 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;
|
|
|
|
// Formats a document.
|
|
auto HandleFormatting(
|
|
Context& context, const clang::clangd::DocumentFormattingParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::TextEdit>>)->void>
|
|
on_done) -> void;
|
|
|
|
// Provides the type of the entity at a position.
|
|
auto HandleHover(
|
|
Context& context, const clang::clangd::TextDocumentPositionParams& params,
|
|
llvm::function_ref<auto(llvm::Expected<clang::clangd::Hover>)->void>
|
|
on_done) -> void;
|
|
|
|
// Locates the implementations of the entity named at a position.
|
|
auto HandleImplementation(
|
|
Context& context, const clang::clangd::TextDocumentPositionParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::Location>>)->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;
|
|
|
|
// Finds references to the entity named at a position, within this file only.
|
|
auto HandleReferences(
|
|
Context& context, const clang::clangd::ReferenceParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::Location>>)->void>
|
|
on_done) -> 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;
|
|
|
|
// Locates the type of the entity named at a position.
|
|
auto HandleTypeDefinition(
|
|
Context& context, const clang::clangd::TextDocumentPositionParams& params,
|
|
llvm::function_ref<
|
|
auto(llvm::Expected<std::vector<clang::clangd::Location>>)->void>
|
|
on_done) -> void;
|
|
|
|
} // namespace Carbon::LanguageServer
|
|
|
|
#endif // CARBON_TOOLCHAIN_LANGUAGE_SERVER_HANDLE_H_
|