Skip to content

Commit a793438

Browse files
authored
Merge pull request #2297 from hamishknight/fix-skip
Fix `sourcekitdSupportsFullDocumentationInCompletion` to not rely on `ideApi`
2 parents 465dab1 + 2aa09ae commit a793438

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

Sources/SKTestSupport/SkipUnless.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,39 @@ package actor SkipUnless {
275275
line: UInt = #line
276276
) async throws {
277277
return try await shared.skipUnlessSupportedByToolchain(swiftVersion: SwiftVersion(6, 2), file: file, line: line) {
278-
let sourcekitd = try await getSourceKitD()
279-
280-
return sourcekitd.ideApi.completion_item_get_doc_raw != nil
278+
let testClient = try await TestSourceKitLSPClient()
279+
let uri = DocumentURI(for: .swift)
280+
let positions = testClient.openDocument(
281+
"""
282+
/// A function
283+
///
284+
/// with full docs
285+
func sourcekitdSupportsFullDocumentationInCompletion() {}
286+
1️⃣
287+
""",
288+
uri: uri
289+
)
290+
let result = try await testClient.send(
291+
CompletionRequest(
292+
textDocument: TextDocumentIdentifier(uri),
293+
position: positions["1️⃣"]
294+
)
295+
)
296+
guard
297+
let item = result.items.first(where: {
298+
$0.label == "sourcekitdSupportsFullDocumentationInCompletion()"
299+
})
300+
else {
301+
XCTFail("Expected to find completion for 'sourcekitdSupportsFullDocumentationInCompletion'")
302+
return false
303+
}
304+
let resolvedItem = try await testClient.send(
305+
CompletionItemResolveRequest(item: item)
306+
)
307+
guard case let .markupContent(markup) = resolvedItem.documentation else {
308+
return false
309+
}
310+
return markup.value.contains("with full docs")
281311
}
282312
}
283313

0 commit comments

Comments
 (0)