mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[SourceKit] Allow explicit cancellation of requests with a cancellation token
The key changes here are - To keep track of cancellation tokens for all `ScheduledConsumer`s in `SwiftASTManager` - Generate unique request handles for all incoming requests (`create_request_handle `), use these request handles as cancellation tokens and return them from the `sourcekitd_send_request` methods - Implement cancellation with `sourcekitd_cancel_request` as the entry point and `SwiftASTManager::cancelASTConsumer` as the termination point Everything else is just plumbing the cancellation token through the various abstraction layers. rdar://83391505
This commit is contained in:
@@ -1407,7 +1407,8 @@ void SwiftLangSupport::findRenameRanges(
|
||||
|
||||
void SwiftLangSupport::findLocalRenameRanges(
|
||||
StringRef Filename, unsigned Line, unsigned Column, unsigned Length,
|
||||
ArrayRef<const char *> Args, CategorizedRenameRangesReceiver Receiver) {
|
||||
ArrayRef<const char *> Args, SourceKitCancellationToken CancellationToken,
|
||||
CategorizedRenameRangesReceiver Receiver) {
|
||||
std::string Error;
|
||||
SwiftInvocationRef Invok = ASTMgr->getInvocation(Args, Filename, Error);
|
||||
if (!Invok) {
|
||||
@@ -1447,6 +1448,7 @@ void SwiftLangSupport::findLocalRenameRanges(
|
||||
/// don't use 'OncePerASTToken'.
|
||||
static const char OncePerASTToken = 0;
|
||||
getASTManager()->processASTAsync(Invok, ASTConsumer, &OncePerASTToken,
|
||||
CancellationToken,
|
||||
llvm::vfs::getRealFileSystem());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user