@@ -27,6 +27,7 @@ import { DiagnosticsManager } from "../DiagnosticsManager";
27
27
import { LSPLogger , LSPOutputChannel } from "./LSPOutputChannel" ;
28
28
import { SwiftOutputChannel } from "../ui/SwiftOutputChannel" ;
29
29
import { promptForDiagnostics } from "../commands/captureDiagnostics" ;
30
+ import { PeekMacroParams , PeekMacroRequest } from "./lspExtensions" ;
30
31
31
32
interface SourceKitLogMessageParams extends langclient . LogMessageParams {
32
33
logName ?: string ;
@@ -616,6 +617,37 @@ export class LanguageClientManager {
616
617
this . languageClient = client ;
617
618
this . cancellationToken = new vscode . CancellationTokenSource ( ) ;
618
619
620
+ this . languageClient . onRequest ( PeekMacroRequest . method , async ( params : PeekMacroParams ) => {
621
+ const locations = params . macroExpansion . expansionURIs . map ( uri => {
622
+ const location = new vscode . Location (
623
+ vscode . Uri . from ( {
624
+ scheme : "file" ,
625
+ path : new URL ( uri ) . pathname ,
626
+ } ) ,
627
+ new vscode . Position ( 0 , 0 )
628
+ ) ;
629
+
630
+ return location ;
631
+ } ) ;
632
+
633
+ console . log ( params . peekLocation ) ;
634
+
635
+ const peekPosition = new vscode . Position (
636
+ params . peekLocation . line ,
637
+ params . peekLocation . character
638
+ ) ;
639
+
640
+ await vscode . commands . executeCommand (
641
+ "editor.action.peekLocations" ,
642
+ vscode . window . activeTextEditor ?. document . uri ,
643
+ peekPosition ,
644
+ locations ,
645
+ "peek"
646
+ ) ;
647
+
648
+ return { success : true } ;
649
+ } ) ;
650
+
619
651
return this . clientReadyPromise ;
620
652
}
621
653
0 commit comments