Author: Keith Smiley Date: 2021-01-25T11:56:18-08:00 New Revision: 9d9ceb37453ffe0186d04f4e9e4ba9fb41200b57
URL: https://github.com/llvm/llvm-project/commit/9d9ceb37453ffe0186d04f4e9e4ba9fb41200b57 DIFF: https://github.com/llvm/llvm-project/commit/9d9ceb37453ffe0186d04f4e9e4ba9fb41200b57.diff LOG: Revert "[clangd][NFC] Simplify handing on methods with no params" This broke the build http://lab.llvm.org:8011/#/builders/7/builds/1405 This reverts commit f05b492aae4d4a741ec59f19518df91a3012824c. Differential Revision: https://reviews.llvm.org/D95385 Added: Modified: clang-tools-extra/clangd/ClangdLSPServer.cpp clang-tools-extra/clangd/ClangdLSPServer.h clang-tools-extra/clangd/Protocol.h Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp index 930cc3f6c5d9..24d3a3509ca8 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.cpp +++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp @@ -258,15 +258,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler { }; } - template <typename Result> - void bind(const char *Method, - void (ClangdLSPServer::*Handler)(Callback<Result>)) { - Calls[Method] = [Handler, this](llvm::json::Value RawParams, - ReplyOnce Reply) { - (Server.*Handler)(std::move(Reply)); - }; - } - // Bind a reply callback to a request. The callback will be invoked when // clangd receives the reply from the LSP client. // Return a call id of the request. @@ -310,20 +301,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler { }; } - void bind(const char *Method, void (ClangdLSPServer::*Handler)()) { - Notifications[Method] = [Handler, this](llvm::json::Value RawParams) { - (Server.*Handler)(); - }; - } - - template <> - void bind<NoParams>(const char *Method, - void (ClangdLSPServer::*Handler)(const NoParams &)) { - Notifications[Method] = [Handler, this](llvm::json::Value RawParams) { - (Server.*Handler)(NoParams{}); - }; - } - private: // Function object to reply to an LSP call. // Each instance must be called exactly once, otherwise: @@ -670,7 +647,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params, void ClangdLSPServer::onInitialized(const InitializedParams &Params) {} -void ClangdLSPServer::onShutdown(Callback<std::nullptr_t> Reply) { +void ClangdLSPServer::onShutdown(const ShutdownParams &Params, + Callback<std::nullptr_t> Reply) { // Do essentially nothing, just say we're ready to exit. ShutdownRequestReceived = true; Reply(nullptr); @@ -678,7 +656,8 @@ void ClangdLSPServer::onShutdown(Callback<std::nullptr_t> Reply) { // sync is a clangd extension: it blocks until all background work completes. // It blocks the calling thread, so no messages are processed until it returns! -void ClangdLSPServer::onSync(Callback<std::nullptr_t> Reply) { +void ClangdLSPServer::onSync(const NoParams &Params, + Callback<std::nullptr_t> Reply) { if (Server->blockUntilIdleForTest(/*TimeoutSeconds=*/60)) Reply(nullptr); else @@ -1466,7 +1445,8 @@ void ClangdLSPServer::onSemanticTokensDelta( }); } -void ClangdLSPServer::onMemoryUsage(Callback<MemoryTree> Reply) { +void ClangdLSPServer::onMemoryUsage(const NoParams &, + Callback<MemoryTree> Reply) { llvm::BumpPtrAllocator DetailAlloc; MemoryTree MT(&DetailAlloc); profile(MT); diff --git a/clang-tools-extra/clangd/ClangdLSPServer.h b/clang-tools-extra/clangd/ClangdLSPServer.h index d8ce2dbe53db..3a46bd7b1bea 100644 --- a/clang-tools-extra/clangd/ClangdLSPServer.h +++ b/clang-tools-extra/clangd/ClangdLSPServer.h @@ -93,8 +93,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks { // Calls have signature void(const Params&, Callback<Response>). void onInitialize(const InitializeParams &, Callback<llvm::json::Value>); void onInitialized(const InitializedParams &); - void onShutdown(Callback<std::nullptr_t>); - void onSync(Callback<std::nullptr_t>); + void onShutdown(const ShutdownParams &, Callback<std::nullptr_t>); + void onSync(const NoParams &, Callback<std::nullptr_t>); void onDocumentDidOpen(const DidOpenTextDocumentParams &); void onDocumentDidChange(const DidChangeTextDocumentParams &); void onDocumentDidClose(const DidCloseTextDocumentParams &); @@ -161,7 +161,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks { Callback<SemanticTokensOrDelta>); /// This is a clangd extension. Provides a json tree representing memory usage /// hierarchy. - void onMemoryUsage(Callback<MemoryTree>); + void onMemoryUsage(const NoParams &, Callback<MemoryTree>); std::vector<Fix> getFixes(StringRef File, const clangd::Diagnostic &D); diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 43c95686868b..9f0e50fe863f 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -265,6 +265,8 @@ inline bool fromJSON(const llvm::json::Value &, NoParams &, llvm::json::Path) { return true; } using InitializedParams = NoParams; +using ShutdownParams = NoParams; +using ExitParams = NoParams; /// Defines how the host (editor) should sync document changes to the language /// server. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits