[SourceKit] Support cancellation of code completion like requests

Essentially, just wire up cancellation tokens and cancellation flags for `CompletionInstance` and make sure to return `CancellableResult::cancelled()` when cancellation is detected.

rdar://83391488
This commit is contained in:
Alex Hoppen
2021-12-02 13:05:03 +01:00
parent d482ee392e
commit 177ab6e8e7
11 changed files with 282 additions and 148 deletions

View File

@@ -158,6 +158,7 @@ void SwiftLangSupport::getConformingMethodList(
llvm::MemoryBuffer *UnresolvedInputFile, unsigned Offset,
OptionsDictionary *optionsDict, ArrayRef<const char *> Args,
ArrayRef<const char *> ExpectedTypeNames,
SourceKitCancellationToken CancellationToken,
SourceKit::ConformingMethodListConsumer &SKConsumer,
Optional<VFSOptions> vfsOptions) {
std::string error;
@@ -175,13 +176,14 @@ void SwiftLangSupport::getConformingMethodList(
}
performWithParamsToCompletionLikeOperation(
UnresolvedInputFile, Offset, Args, fileSystem,
UnresolvedInputFile, Offset, Args, fileSystem, CancellationToken,
[&](CancellableResult<CompletionLikeOperationParams> ParmsResult) {
ParmsResult.mapAsync<ConformingMethodListResults>(
[&](auto &Params, auto DeliverTransformed) {
getCompletionInstance()->conformingMethodList(
Params.Invocation, Args, fileSystem, Params.completionBuffer,
Offset, Params.DiagC, ExpectedTypeNames, DeliverTransformed);
Offset, Params.DiagC, ExpectedTypeNames,
Params.CancellationFlag, DeliverTransformed);
},
[&](auto Result) { deliverResults(SKConsumer, Result); });
});