Skip to content

Commit 9d9ceb3

Browse files
committed
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 f05b492. Differential Revision: https://reviews.llvm.org/D95385
1 parent 9946b16 commit 9d9ceb3

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
258258
};
259259
}
260260

261-
template <typename Result>
262-
void bind(const char *Method,
263-
void (ClangdLSPServer::*Handler)(Callback<Result>)) {
264-
Calls[Method] = [Handler, this](llvm::json::Value RawParams,
265-
ReplyOnce Reply) {
266-
(Server.*Handler)(std::move(Reply));
267-
};
268-
}
269-
270261
// Bind a reply callback to a request. The callback will be invoked when
271262
// clangd receives the reply from the LSP client.
272263
// Return a call id of the request.
@@ -310,20 +301,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
310301
};
311302
}
312303

313-
void bind(const char *Method, void (ClangdLSPServer::*Handler)()) {
314-
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
315-
(Server.*Handler)();
316-
};
317-
}
318-
319-
template <>
320-
void bind<NoParams>(const char *Method,
321-
void (ClangdLSPServer::*Handler)(const NoParams &)) {
322-
Notifications[Method] = [Handler, this](llvm::json::Value RawParams) {
323-
(Server.*Handler)(NoParams{});
324-
};
325-
}
326-
327304
private:
328305
// Function object to reply to an LSP call.
329306
// Each instance must be called exactly once, otherwise:
@@ -670,15 +647,17 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
670647

671648
void ClangdLSPServer::onInitialized(const InitializedParams &Params) {}
672649

673-
void ClangdLSPServer::onShutdown(Callback<std::nullptr_t> Reply) {
650+
void ClangdLSPServer::onShutdown(const ShutdownParams &Params,
651+
Callback<std::nullptr_t> Reply) {
674652
// Do essentially nothing, just say we're ready to exit.
675653
ShutdownRequestReceived = true;
676654
Reply(nullptr);
677655
}
678656

679657
// sync is a clangd extension: it blocks until all background work completes.
680658
// It blocks the calling thread, so no messages are processed until it returns!
681-
void ClangdLSPServer::onSync(Callback<std::nullptr_t> Reply) {
659+
void ClangdLSPServer::onSync(const NoParams &Params,
660+
Callback<std::nullptr_t> Reply) {
682661
if (Server->blockUntilIdleForTest(/*TimeoutSeconds=*/60))
683662
Reply(nullptr);
684663
else
@@ -1466,7 +1445,8 @@ void ClangdLSPServer::onSemanticTokensDelta(
14661445
});
14671446
}
14681447

1469-
void ClangdLSPServer::onMemoryUsage(Callback<MemoryTree> Reply) {
1448+
void ClangdLSPServer::onMemoryUsage(const NoParams &,
1449+
Callback<MemoryTree> Reply) {
14701450
llvm::BumpPtrAllocator DetailAlloc;
14711451
MemoryTree MT(&DetailAlloc);
14721452
profile(MT);

clang-tools-extra/clangd/ClangdLSPServer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
9393
// Calls have signature void(const Params&, Callback<Response>).
9494
void onInitialize(const InitializeParams &, Callback<llvm::json::Value>);
9595
void onInitialized(const InitializedParams &);
96-
void onShutdown(Callback<std::nullptr_t>);
97-
void onSync(Callback<std::nullptr_t>);
96+
void onShutdown(const ShutdownParams &, Callback<std::nullptr_t>);
97+
void onSync(const NoParams &, Callback<std::nullptr_t>);
9898
void onDocumentDidOpen(const DidOpenTextDocumentParams &);
9999
void onDocumentDidChange(const DidChangeTextDocumentParams &);
100100
void onDocumentDidClose(const DidCloseTextDocumentParams &);
@@ -161,7 +161,7 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
161161
Callback<SemanticTokensOrDelta>);
162162
/// This is a clangd extension. Provides a json tree representing memory usage
163163
/// hierarchy.
164-
void onMemoryUsage(Callback<MemoryTree>);
164+
void onMemoryUsage(const NoParams &, Callback<MemoryTree>);
165165

166166
std::vector<Fix> getFixes(StringRef File, const clangd::Diagnostic &D);
167167

clang-tools-extra/clangd/Protocol.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ inline bool fromJSON(const llvm::json::Value &, NoParams &, llvm::json::Path) {
265265
return true;
266266
}
267267
using InitializedParams = NoParams;
268+
using ShutdownParams = NoParams;
269+
using ExitParams = NoParams;
268270

269271
/// Defines how the host (editor) should sync document changes to the language
270272
/// server.

0 commit comments

Comments
 (0)