1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:04:49 -07:00

internal/lsp: decorate error message from workspace/configuration

Fixes golang/go#39896

Change-Id: Ib63e3b4b716f6005b3cbbc92ede40fdbfc8ca22f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240619
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-06-30 17:55:40 -04:00
parent c138986dd9
commit a32c0cb1d5

View File

@ -239,32 +239,38 @@ func (s *Server) fetchConfig(ctx context.Context, name string, folder span.URI,
}
configs, err := s.client.Configuration(ctx, &v)
if err != nil {
return err
return fmt.Errorf("failed to get workspace configuration from client (%s): %v", folder, err)
}
for _, config := range configs {
results := source.SetOptions(o, config)
for _, result := range results {
if result.Error != nil {
s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
if err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
Type: protocol.Error,
Message: result.Error.Error(),
})
}); err != nil {
return err
}
}
switch result.State {
case source.OptionUnexpected:
s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
if err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
Type: protocol.Error,
Message: fmt.Sprintf("unexpected config %s", result.Name),
})
}); err != nil {
return err
}
case source.OptionDeprecated:
msg := fmt.Sprintf("config %s is deprecated", result.Name)
if result.Replacement != "" {
msg = fmt.Sprintf("%s, use %s instead", msg, result.Replacement)
}
s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
if err := s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
Type: protocol.Warning,
Message: msg,
})
}); err != nil {
return err
}
}
}
}