Skip to content

Commit

Permalink
🐛 handle progress messages from lang server (#657)
Browse files Browse the repository at this point in the history
Signed-off-by: David Zager <[email protected]>
  • Loading branch information
djzager authored Jul 15, 2024
1 parent 66df777 commit dc66315
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ func (p *dotnetProvider) Init(ctx context.Context, log logr.Logger, config provi
},
// WorkspaceFolders: true,
},
Window: &protocol.WindowClientCapabilities{
WorkDoneProgress: false,
},
},
// WorkspaceFolders: []protocol.WorkspaceFolder{
// protocol.WorkspaceFolder{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,18 @@ type handler struct {

func (h *handler) replyHandler(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error {
method := req.Method()
h.log.Info("Got request for " + method)
// params, _ := req.Params().MarshalJSON()
switch method {
case protocol.MethodClientRegisterCapability:
h.log.V(2).Info("Got request for " + protocol.MethodClientRegisterCapability)
err := reply(ctx, nil, nil)
// h.ch <- 1
return err
case protocol.MethodWorkspaceConfiguration:
h.log.V(2).Info("Got request for " + protocol.MethodWorkspaceConfiguration)
err := reply(ctx, nil, nil)
// h.ch <- 2
return err
case protocol.MethodWindowShowMessage:
h.log.V(2).Info("Got request for " + protocol.MethodWindowShowMessage)
var showMessageParams protocol.ShowMessageParams
if err := json.Unmarshal(req.Params(), &showMessageParams); err != nil {
return reply(ctx, nil, err)
Expand All @@ -279,8 +277,28 @@ func (h *handler) replyHandler(ctx context.Context, reply jsonrpc2.Replier, req
h.ch <- 3
}
return err
case protocol.MethodProgress:
var methodProgressParams protocol.ProgressParams
if err := json.Unmarshal(req.Params(), &methodProgressParams); err != nil {
return reply(ctx, nil, err)
}
h.log.Info("Progress message", "params", methodProgressParams)
err := reply(ctx, nil, nil)
valueMap, _ := methodProgressParams.Value.(map[string]interface{})
if message, ok := valueMap["message"]; ok {
h.log.Info("Extracted message", "message", message)
if strings.Contains(message.(string), "finished loading solution") {
h.ch <- 3
}
} else {
err = fmt.Errorf("Something terrible has happened loading progress message")
}
return err
case protocol.MethodWorkDoneProgressCreate, protocol.MethodWorkDoneProgressCancel:
err := reply(ctx, nil, nil)
return err
}

h.log.Info("I don't know what to do with this", req)
h.log.Info("I don't know what to do with this", "request", req)
return jsonrpc2.MethodNotFoundHandler(ctx, reply, req)
}

0 comments on commit dc66315

Please sign in to comment.