Files
carbon-lang/toolchain/language_server/outgoing_messages.h
T
Jon Ross-Perkins 96d836f965 Refactor the language server structure. (#4721)
I'm trying to make the LSP look more like the rest of the toolchain. I'm
trying to separate the handlers from the transport layer, and remove the
multiple inheritance aspect. Also fixing some style issues, switching to
`Map`, and removing an unnecessary copt.

I'm using `Context` for the central object for consistency with other
portions of the toolchain. In order to get the `handle_*` files working,
I'm using LLVM's registry class. It has a quirk that I can't register
two registries in the same cpp file, so there are two one-line cpp
files.

In order to help show the delta (or lack thereof) for actual
implementation, I've copied server.cpp over handle_* and undone that in
two commits. See the third and fourth commits on the PR history for
that.
2025-01-08 06:01:51 +00:00

39 lines
1.3 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_OUTGOING_MESSAGES_H_
#define CARBON_TOOLCHAIN_LANGUAGE_SERVER_OUTGOING_MESSAGES_H_
#include "clang-tools-extra/clangd/LSPBinder.h"
#include "clang-tools-extra/clangd/Transport.h"
namespace Carbon::LanguageServer {
// Handles sending LSP messages to the client (IDE extension).
class OutgoingMessages : public clang::clangd::LSPBinder::RawOutgoing {
public:
explicit OutgoingMessages(clang::clangd::Transport* transport)
: transport_(transport) {}
// Calls a method on the client.
// TODO: Implement when needed.
auto callMethod(llvm::StringRef /*method*/, llvm::json::Value /*params*/,
clang::clangd::Callback<llvm::json::Value> /*reply*/)
-> void override {}
// Sets a notification to the client.
auto notify(llvm::StringRef method, llvm::json::Value params)
-> void override {
transport_->notify(method, params);
}
private:
// The connection to the client.
clang::clangd::Transport* transport_;
};
} // namespace Carbon::LanguageServer
#endif // CARBON_TOOLCHAIN_LANGUAGE_SERVER_OUTGOING_MESSAGES_H_