From 2aa09ae0a1776cb4c627d48c9fd5e7a96a010415 Mon Sep 17 00:00:00 2001 From: Hamish Knight Date: Thu, 18 Sep 2025 14:27:21 +0100 Subject: [PATCH] Fix `sourcekitdSupportsFullDocumentationInCompletion` to not rely on `ideApi` `ideApi` is only available within the plugin itself, it's not available to sourcekitd. Switch to sending a completion request and checking that we get full documentation back. --- Sources/SKTestSupport/SkipUnless.swift | 36 +++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Sources/SKTestSupport/SkipUnless.swift b/Sources/SKTestSupport/SkipUnless.swift index c101f8816..8134a5a36 100644 --- a/Sources/SKTestSupport/SkipUnless.swift +++ b/Sources/SKTestSupport/SkipUnless.swift @@ -275,9 +275,39 @@ package actor SkipUnless { line: UInt = #line ) async throws { return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 2), file: file, line: line) { - let sourcekitd = try await getSourceKitD() - - return sourcekitd.ideApi.completion_item_get_doc_raw != nil + let testClient = try await TestSourceKitLSPClient() + let uri = DocumentURI(for: .swift) + let positions = testClient.openDocument( + """ + /// A function + /// + /// with full docs + func sourcekitdSupportsFullDocumentationInCompletion() {} + 1️⃣ + """, + uri: uri + ) + let result = try await testClient.send( + CompletionRequest( + textDocument: TextDocumentIdentifier(uri), + position: positions["1️⃣"] + ) + ) + guard + let item = result.items.first(where: { + $0.label == "sourcekitdSupportsFullDocumentationInCompletion()" + }) + else { + XCTFail("Expected to find completion for 'sourcekitdSupportsFullDocumentationInCompletion'") + return false + } + let resolvedItem = try await testClient.send( + CompletionItemResolveRequest(item: item) + ) + guard case let .markupContent(markup) = resolvedItem.documentation else { + return false + } + return markup.value.contains("with full docs") } }