[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 810fbcee9c
commit 5bd9e439ee
6 changed files with 56 additions and 14 deletions

View File

@@ -853,6 +853,7 @@ public:
void SwiftLangSupport::editorOpenSwiftSourceInterface(
StringRef Name, StringRef SourceName, ArrayRef<const char *> Args,
bool CancelOnSubsequentRequest,
SourceKitCancellationToken CancellationToken,
std::shared_ptr<EditorConsumer> Consumer) {
std::string Error;
@@ -864,7 +865,8 @@ void SwiftLangSupport::editorOpenSwiftSourceInterface(
auto AstConsumer = std::make_shared<PrimaryFileInterfaceConsumer>(Name,
SourceName, IFaceGenContexts, Consumer, Invocation);
static const char OncePerASTToken = 0;
getASTManager()->processASTAsync(Invocation, AstConsumer, &OncePerASTToken,
const void *Once = CancelOnSubsequentRequest ? &OncePerASTToken : nullptr;
getASTManager()->processASTAsync(Invocation, AstConsumer, Once,
CancellationToken,
llvm::vfs::getRealFileSystem());
}