@@ -260,7 +260,7 @@ func (s *Server) readLoop(ctx context.Context) error {
260
260
if s .initializeParams == nil && msg .Kind == lsproto .MessageKindRequest {
261
261
req := msg .AsRequest ()
262
262
if req .Method == lsproto .MethodInitialize {
263
- resp , err := s .handleInitialize (ctx , req .Params .(* lsproto.InitializeParams ), func () {} )
263
+ resp , err := s .handleInitialize (ctx , req .Params .(* lsproto.InitializeParams ), req )
264
264
if err != nil {
265
265
return err
266
266
}
@@ -480,16 +480,18 @@ func registerNotificationHandler[Req any](handlers handlerMap, info lsproto.Noti
480
480
}
481
481
}
482
482
483
- func registerRequestHandler [Req , Resp any ](handlers handlerMap , info lsproto.RequestInfo [Req , Resp ], fn func (* Server , context.Context , Req , func ()) (Resp , error )) {
483
+ func registerRequestHandler [Req , Resp any ](
484
+ handlers handlerMap ,
485
+ info lsproto.RequestInfo [Req , Resp ],
486
+ fn func (* Server , context.Context , Req , * lsproto.RequestMessage ) (Resp , error ),
487
+ ) {
484
488
handlers [info .Method ] = func (s * Server , ctx context.Context , req * lsproto.RequestMessage ) error {
485
489
var params Req
486
490
// Ignore empty params.
487
491
if req .Params != nil {
488
492
params = req .Params .(Req )
489
493
}
490
- resp , err := fn (s , ctx , params , func () {
491
- s .recover (req )
492
- })
494
+ resp , err := fn (s , ctx , params , req )
493
495
if err != nil {
494
496
return err
495
497
}
@@ -537,7 +539,7 @@ func (s *Server) recover(req *lsproto.RequestMessage) {
537
539
}
538
540
}
539
541
540
- func (s * Server ) handleInitialize (ctx context.Context , params * lsproto.InitializeParams , _ func () ) (lsproto.InitializeResponse , error ) {
542
+ func (s * Server ) handleInitialize (ctx context.Context , params * lsproto.InitializeParams , _ * lsproto. RequestMessage ) (lsproto.InitializeResponse , error ) {
541
543
if s .initializeParams != nil {
542
544
return nil , lsproto .ErrInvalidRequest
543
545
}
@@ -661,7 +663,7 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali
661
663
return nil
662
664
}
663
665
664
- func (s * Server ) handleShutdown (ctx context.Context , params any , _ func () ) (lsproto.ShutdownResponse , error ) {
666
+ func (s * Server ) handleShutdown (ctx context.Context , params any , _ * lsproto. RequestMessage ) (lsproto.ShutdownResponse , error ) {
665
667
s .session .Close ()
666
668
return lsproto.ShutdownResponse {}, nil
667
669
}
@@ -758,7 +760,7 @@ func (s *Server) handleCompletion(ctx context.Context, languageService *ls.Langu
758
760
& ls.UserPreferences {})
759
761
}
760
762
761
- func (s * Server ) handleCompletionItemResolve (ctx context.Context , params * lsproto.CompletionItem , recoverAndSendError func () ) (lsproto.CompletionResolveResponse , error ) {
763
+ func (s * Server ) handleCompletionItemResolve (ctx context.Context , params * lsproto.CompletionItem , reqMsg * lsproto. RequestMessage ) (lsproto.CompletionResolveResponse , error ) {
762
764
data , err := ls .GetCompletionItemData (params )
763
765
if err != nil {
764
766
return nil , err
@@ -767,7 +769,7 @@ func (s *Server) handleCompletionItemResolve(ctx context.Context, params *lsprot
767
769
if err != nil {
768
770
return nil , err
769
771
}
770
- defer recoverAndSendError ( )
772
+ defer s . recover ( reqMsg )
771
773
return languageService .ResolveCompletionItem (
772
774
ctx ,
773
775
params ,
@@ -804,10 +806,10 @@ func (s *Server) handleDocumentOnTypeFormat(ctx context.Context, ls *ls.Language
804
806
)
805
807
}
806
808
807
- func (s * Server ) handleWorkspaceSymbol (ctx context.Context , params * lsproto.WorkspaceSymbolParams , recoverAndSendError func () ) (lsproto.WorkspaceSymbolResponse , error ) {
809
+ func (s * Server ) handleWorkspaceSymbol (ctx context.Context , params * lsproto.WorkspaceSymbolParams , reqMsg * lsproto. RequestMessage ) (lsproto.WorkspaceSymbolResponse , error ) {
808
810
snapshot , release := s .session .Snapshot ()
809
811
defer release ()
810
- defer recoverAndSendError ( )
812
+ defer s . recover ( reqMsg )
811
813
programs := core .Map (snapshot .ProjectCollection .Projects (), (* project .Project ).GetProgram )
812
814
return ls .ProvideWorkspaceSymbols (ctx , programs , snapshot .Converters (), params .Query )
813
815
}
0 commit comments