@@ -28,6 +28,7 @@ import { DiagnosticsManager } from "../DiagnosticsManager";
2828import { LSPLogger , LSPOutputChannel } from "./LSPOutputChannel" ;
2929import { SwiftOutputChannel } from "../ui/SwiftOutputChannel" ;
3030import { promptForDiagnostics } from "../commands/captureDiagnostics" ;
31+ import { activateGetReferenceDocument } from "./getReferenceDocument" ;
3132
3233interface SourceKitLogMessageParams extends langclient . LogMessageParams {
3334 logName ?: string ;
@@ -110,6 +111,7 @@ export class LanguageClientManager {
110111 private cancellationToken ?: vscode . CancellationTokenSource ;
111112 private legacyInlayHints ?: vscode . Disposable ;
112113 private peekDocuments ?: vscode . Disposable ;
114+ private getReferenceDocument ?: vscode . Disposable ;
113115 private restartedPromise ?: Promise < void > ;
114116 private currentWorkspaceFolder ?: vscode . Uri ;
115117 private waitingOnRestartCount : number ;
@@ -247,6 +249,7 @@ export class LanguageClientManager {
247249 this . cancellationToken ?. dispose ( ) ;
248250 this . legacyInlayHints ?. dispose ( ) ;
249251 this . peekDocuments ?. dispose ( ) ;
252+ this . getReferenceDocument ?. dispose ( ) ;
250253 this . subscriptions . forEach ( item => item . dispose ( ) ) ;
251254 this . languageClient ?. stop ( ) ;
252255 this . namedOutputChannels . forEach ( channel => channel . dispose ( ) ) ;
@@ -397,6 +400,8 @@ export class LanguageClientManager {
397400 this . legacyInlayHints = undefined ;
398401 this . peekDocuments ?. dispose ( ) ;
399402 this . peekDocuments = undefined ;
403+ this . getReferenceDocument ?. dispose ( ) ;
404+ this . getReferenceDocument = undefined ;
400405 if ( client ) {
401406 this . cancellationToken ?. cancel ( ) ;
402407 this . cancellationToken ?. dispose ( ) ;
@@ -573,6 +578,7 @@ export class LanguageClientManager {
573578 initializationFailedHandler : ( ) => false ,
574579 initializationOptions : {
575580 "workspace/peekDocuments" : true , // workaround for client capability to handle `PeekDocumentsRequest`
581+ "workspace/getReferenceDocument" : true , // the client can handle URIs with scheme `sourcekit-lsp:`
576582 "textDocument/codeLens" : {
577583 supportedCommands : {
578584 "swift.run" : "swift.run" ,
@@ -636,6 +642,8 @@ export class LanguageClientManager {
636642 }
637643
638644 this . peekDocuments = activatePeekDocuments ( client ) ;
645+ this . getReferenceDocument = activateGetReferenceDocument ( client ) ;
646+ this . workspaceContext . subscriptions . push ( this . getReferenceDocument ) ;
639647 } )
640648 . catch ( reason => {
641649 this . workspaceContext . outputChannel . log ( `${ reason } ` ) ;
0 commit comments