@@ -264,7 +264,6 @@ class CodeCompletionSession {
264
264
self . clientSupportsDocumentationResolve =
265
265
clientCapabilities. textDocument? . completion? . completionItem? . resolveSupport? . properties. contains ( " documentation " )
266
266
?? false
267
-
268
267
}
269
268
270
269
private func open(
@@ -279,7 +278,6 @@ class CodeCompletionSession {
279
278
280
279
let sourcekitdPosition = snapshot. sourcekitdPosition ( of: self . position)
281
280
let req = sourcekitd. dictionary ( [
282
- keys. request: sourcekitd. requests. codeCompleteOpen,
283
281
keys. line: sourcekitdPosition. line,
284
282
keys. column: sourcekitdPosition. utf8Column,
285
283
keys. name: uri. pseudoPath,
@@ -288,7 +286,7 @@ class CodeCompletionSession {
288
286
keys. codeCompleteOptions: optionsDictionary ( filterText: filterText) ,
289
287
] )
290
288
291
- let dict = try await sendSourceKitdRequest ( req, snapshot: snapshot)
289
+ let dict = try await send ( sourceKitDRequest : \ . codeCompleteOpen , req, snapshot: snapshot)
292
290
self . state = . open
293
291
294
292
guard let completions: SKDResponseArray = dict [ keys. results] else {
@@ -314,15 +312,14 @@ class CodeCompletionSession {
314
312
logger. info ( " Updating code completion session: \( self . description) filter= \( filterText) " )
315
313
let sourcekitdPosition = snapshot. sourcekitdPosition ( of: self . position)
316
314
let req = sourcekitd. dictionary ( [
317
- keys. request: sourcekitd. requests. codeCompleteUpdate,
318
315
keys. line: sourcekitdPosition. line,
319
316
keys. column: sourcekitdPosition. utf8Column,
320
317
keys. name: uri. pseudoPath,
321
318
keys. sourceFile: uri. pseudoPath,
322
319
keys. codeCompleteOptions: optionsDictionary ( filterText: filterText) ,
323
320
] )
324
321
325
- let dict = try await sendSourceKitdRequest ( req, snapshot: snapshot)
322
+ let dict = try await send ( sourceKitDRequest : \ . codeCompleteUpdate , req, snapshot: snapshot)
326
323
guard let completions: SKDResponseArray = dict [ keys. results] else {
327
324
return CompletionList ( isIncomplete: false , items: [ ] )
328
325
}
@@ -363,29 +360,31 @@ class CodeCompletionSession {
363
360
case . open:
364
361
let sourcekitdPosition = snapshot. sourcekitdPosition ( of: self . position)
365
362
let req = sourcekitd. dictionary ( [
366
- keys. request: sourcekitd. requests. codeCompleteClose,
367
363
keys. line: sourcekitdPosition. line,
368
364
keys. column: sourcekitdPosition. utf8Column,
369
365
keys. sourceFile: snapshot. uri. pseudoPath,
370
366
keys. name: snapshot. uri. pseudoPath,
371
367
keys. codeCompleteOptions: [ keys. useNewAPI: 1 ] ,
372
368
] )
373
369
logger. info ( " Closing code completion session: \( self . description) " )
374
- _ = try ? await sendSourceKitdRequest ( req, snapshot: nil )
370
+ _ = try ? await send ( sourceKitDRequest : \ . codeCompleteClose , req, snapshot: nil )
375
371
self . state = . closed
376
372
}
377
373
}
378
374
379
375
// MARK: - Helpers
380
376
381
- private func sendSourceKitdRequest(
377
+ private func send(
378
+ sourceKitDRequest requestUid: KeyPath < sourcekitd_api_requests , sourcekitd_api_uid_t > & Sendable ,
382
379
_ request: SKDRequestDictionary ,
383
380
snapshot: DocumentSnapshot ?
384
381
) async throws -> SKDResponseDictionary {
385
382
try await sourcekitd. send (
383
+ requestUid,
386
384
request,
387
385
timeout: options. sourcekitdRequestTimeoutOrDefault,
388
386
restartTimeout: options. semanticServiceRestartTimeoutOrDefault,
387
+ documentUrl: snapshot? . uri. arbitrarySchemeURL,
389
388
fileContents: snapshot? . text
390
389
)
391
390
}
@@ -560,11 +559,17 @@ class CodeCompletionSession {
560
559
var item = item
561
560
if let itemId = CompletionItemData ( fromLSPAny: item. data) ? . itemId {
562
561
let req = sourcekitd. dictionary ( [
563
- sourcekitd. keys. request: sourcekitd. requests. codeCompleteDocumentation,
564
- sourcekitd. keys. identifier: itemId,
562
+ sourcekitd. keys. identifier: itemId
565
563
] )
566
564
let documentationResponse = await orLog ( " Retrieving documentation for completion item " ) {
567
- try await sourcekitd. send ( req, timeout: timeout, restartTimeout: restartTimeout, fileContents: nil )
565
+ try await sourcekitd. send (
566
+ \. codeCompleteDocumentation,
567
+ req,
568
+ timeout: timeout,
569
+ restartTimeout: restartTimeout,
570
+ documentUrl: nil ,
571
+ fileContents: nil
572
+ )
568
573
}
569
574
if let docString: String = documentationResponse ? [ sourcekitd. keys. docBrief] {
570
575
item. documentation = . markupContent( MarkupContent ( kind: . markdown, value: docString) )
0 commit comments