[SourceKit] Allow passing cancel_on_subsequent_request: 0 for all requests that use a OncePerASTToken

We need this option for `collectVariableType` (aka inlay type hints) but since I’m at it, I’m adding an option to disable the implicit request cancellation for all requests that have it since we don’t want it in LSP at all.

Prerequisite to fixing https://github.com/swiftlang/sourcekit-lsp/issues/2021 / rdar://145871554, need to adopt this option in SourceKit-LSP.
This commit is contained in:
Alex Hoppen
2025-05-14 18:42:19 +02:00
parent eac419b8ca
commit 9d30958066
6 changed files with 56 additions and 14 deletions

View File

@@ -1418,7 +1418,8 @@ SwiftLangSupport::findRenameRanges(llvm::MemoryBuffer *InputBuf,
void SwiftLangSupport::findLocalRenameRanges(
StringRef Filename, unsigned Line, unsigned Column, unsigned Length,
ArrayRef<const char *> Args, SourceKitCancellationToken CancellationToken,
ArrayRef<const char *> Args, bool CancelOnSubsequentRequest,
SourceKitCancellationToken CancellationToken,
CategorizedRenameRangesReceiver Receiver) {
using ResultType = CancellableResult<std::vector<CategorizedRenameRanges>>;
std::string Error;
@@ -1465,8 +1466,8 @@ void SwiftLangSupport::findLocalRenameRanges(
/// FIXME: When request cancellation is implemented and Xcode adopts it,
/// don't use 'OncePerASTToken'.
static const char OncePerASTToken = 0;
getASTManager()->processASTAsync(Invok, ASTConsumer, &OncePerASTToken,
CancellationToken,
const void *Once = CancelOnSubsequentRequest ? &OncePerASTToken : nullptr;
getASTManager()->processASTAsync(Invok, ASTConsumer, Once, CancellationToken,
llvm::vfs::getRealFileSystem());
}