diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-09-13 12:58:36 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-09-13 12:58:36 +0000 |
| commit | 45be5cf0edd40426b6e8814d9b6814a6b62c722e (patch) | |
| tree | 219f2373ca408917f30e23c5a333f2867cf8756a /clang-tools-extra/clangd/ClangdServer.cpp | |
| parent | 76b88d8e98401902189d78f710163edf7654ace6 (diff) | |
| download | bcm5719-llvm-45be5cf0edd40426b6e8814d9b6814a6b62c722e.tar.gz bcm5719-llvm-45be5cf0edd40426b6e8814d9b6814a6b62c722e.zip | |
[clangd] Allow all LSP methods to signal cancellation via $/cancelRequest
Summary:
The cancelable scopes are managed by JSONRPCDispatcher so that all Handlers
run in cancelable contexts.
(Previously ClangdServer did this, for code completion only).
Cancellation request processing is therefore also in JSONRPCDispatcher.
(Previously it was in ClangdLSPServer).
This doesn't actually make any new commands *respect* cancellation - they'd
need to check isCancelled() and bail out. But it opens the door to doing
this incrementally, and putting such logic in common machinery like TUScheduler.
I also rewrote the ClangdServer class/threading comments because I wanted to
add to it and I got carried away.
Reviewers: ilya-biryukov, kadircet
Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits
Differential Revision: https://reviews.llvm.org/D52004
llvm-svn: 342135
Diffstat (limited to 'clang-tools-extra/clangd/ClangdServer.cpp')
| -rw-r--r-- | clang-tools-extra/clangd/ClangdServer.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp index 20af72fb451..fb4f1be527e 100644 --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -8,7 +8,6 @@ //===-------------------------------------------------------------------===// #include "ClangdServer.h" -#include "Cancellation.h" #include "CodeComplete.h" #include "FindSymbols.h" #include "Headers.h" @@ -201,16 +200,14 @@ void ClangdServer::removeDocument(PathRef File) { WorkScheduler.remove(File); } -Canceler ClangdServer::codeComplete(PathRef File, Position Pos, - const clangd::CodeCompleteOptions &Opts, - Callback<CodeCompleteResult> CB) { +void ClangdServer::codeComplete(PathRef File, Position Pos, + const clangd::CodeCompleteOptions &Opts, + Callback<CodeCompleteResult> CB) { // Copy completion options for passing them to async task handler. auto CodeCompleteOpts = Opts; if (!CodeCompleteOpts.Index) // Respect overridden index. CodeCompleteOpts.Index = Index; - auto Cancelable = cancelableTask(); - WithContext ContextWithCancellation(std::move(Cancelable.first)); // Copy PCHs to avoid accessing this->PCHs concurrently std::shared_ptr<PCHContainerOperations> PCHs = this->PCHs; auto FS = FSProvider.getFileSystem(); @@ -259,7 +256,6 @@ Canceler ClangdServer::codeComplete(PathRef File, Position Pos, // We use a potentially-stale preamble because latency is critical here. WorkScheduler.runWithPreamble("CodeComplete", File, TUScheduler::Stale, Bind(Task, File.str(), std::move(CB))); - return std::move(Cancelable.second); } void ClangdServer::signatureHelp(PathRef File, Position Pos, |

