Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ var handlers = sync.OnceValue(func() handlerMap {

func registerNotificationHandler[Req any](handlers handlerMap, info lsproto.NotificationInfo[Req], fn func(*Server, context.Context, Req) error) {
handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error {
if s.session == nil && req.Method != lsproto.MethodInitialized {
return lsproto.ErrServerNotInitialized
}

var params Req
// Ignore empty params; all generated params are either pointers or any.
if req.Params != nil {
Expand All @@ -486,6 +490,10 @@ func registerRequestHandler[Req, Resp any](
fn func(*Server, context.Context, Req, *lsproto.RequestMessage) (Resp, error),
) {
handlers[info.Method] = func(s *Server, ctx context.Context, req *lsproto.RequestMessage) error {
if s.session == nil && req.Method != lsproto.MethodInitialize {
return lsproto.ErrServerNotInitialized
}

var params Req
// Ignore empty params.
if req.Params != nil {
Expand Down
Loading