mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-29 00:21:14 +00:00
[clangd] Pass raw client capabilities to modules. NFC
This commit is contained in:
parent
22a52dfddc
commit
4d700fb060
@ -582,7 +582,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
|
||||
bindMethods(Binder);
|
||||
if (Opts.Modules)
|
||||
for (auto &Mod : *Opts.Modules)
|
||||
Mod.initializeLSP(Binder, Params.capabilities, ServerCaps);
|
||||
Mod.initializeLSP(Binder, Params.rawCapabilities, ServerCaps);
|
||||
}
|
||||
|
||||
// Per LSP, renameProvider can be either boolean or RenameOptions.
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_MODULE_H
|
||||
|
||||
#include "LSPBinder.h"
|
||||
#include "Protocol.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/JSON.h"
|
||||
#include <memory>
|
||||
@ -37,9 +36,8 @@ public:
|
||||
///
|
||||
/// This is only called if the module is running in ClangdLSPServer!
|
||||
/// Modules with a public interface should satisfy it without LSP bindings.
|
||||
// FIXME: ClientCaps should be a raw json::Object here.
|
||||
virtual void initializeLSP(LSPBinder &Bind,
|
||||
const ClientCapabilities &ClientCaps,
|
||||
const llvm::json::Object &ClientCaps,
|
||||
llvm::json::Object &ServerCaps) {}
|
||||
};
|
||||
|
||||
|
@ -430,6 +430,8 @@ bool fromJSON(const llvm::json::Value &Params, InitializeParams &R,
|
||||
O.map("rootUri", R.rootUri);
|
||||
O.map("rootPath", R.rootPath);
|
||||
O.map("capabilities", R.capabilities);
|
||||
if (auto *RawCaps = Params.getAsObject()->getObject("capabilities"))
|
||||
R.rawCapabilities = *RawCaps;
|
||||
O.map("trace", R.trace);
|
||||
O.map("initializationOptions", R.initializationOptions);
|
||||
return true;
|
||||
|
@ -540,6 +540,8 @@ struct InitializeParams {
|
||||
|
||||
/// The capabilities provided by the client (editor or tool)
|
||||
ClientCapabilities capabilities;
|
||||
/// The same data as capabilities, but not parsed (to expose to modules).
|
||||
llvm::json::Object rawCapabilities;
|
||||
|
||||
/// The initial trace setting. If omitted trace is disabled ('off').
|
||||
llvm::Optional<TraceLevel> trace;
|
||||
|
@ -223,7 +223,7 @@ CompileFlags:
|
||||
|
||||
TEST_F(LSPTest, ModulesTest) {
|
||||
class MathModule : public Module {
|
||||
void initializeLSP(LSPBinder &Bind, const ClientCapabilities &ClientCaps,
|
||||
void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
|
||||
llvm::json::Object &ServerCaps) override {
|
||||
Bind.notification("add", this, &MathModule::add);
|
||||
Bind.method("get", this, &MathModule::get);
|
||||
|
Loading…
Reference in New Issue
Block a user