internal/lsp: ignore errors for completion and signature help
This change makes sure that we never return error messages for completions and signature help requests - just empty results. Change-Id: I00d75cd116daab63beb07f2344e47aac01bb64ee Reviewed-on: https://go-review.googlesource.com/c/tools/+/170958 Reviewed-by: Ian Cottrell <iancottrell@google.com> Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9e5445377b
commit
96f2e7ef86
|
@ -33,7 +33,8 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara
|
||||||
}
|
}
|
||||||
items, prefix, err := source.Completion(ctx, f, rng.Start)
|
items, prefix, err := source.Completion(ctx, f, rng.Start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
s.log.Infof(ctx, "no completions found for %s:%v:%v", uri, int(params.Position.Line), int(params.Position.Character))
|
||||||
|
items = []source.CompletionItem{}
|
||||||
}
|
}
|
||||||
return &protocol.CompletionList{
|
return &protocol.CompletionList{
|
||||||
IsIncomplete: false,
|
IsIncomplete: false,
|
||||||
|
|
|
@ -395,7 +395,7 @@ func (s *Server) SignatureHelp(ctx context.Context, params *protocol.TextDocumen
|
||||||
}
|
}
|
||||||
info, err := source.SignatureHelp(ctx, f, rng.Start)
|
info, err := source.SignatureHelp(ctx, f, rng.Start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
s.log.Infof(ctx, "no signature help for %s:%v:%v", uri, int(params.Position.Line), int(params.Position.Character))
|
||||||
}
|
}
|
||||||
return toProtocolSignatureHelp(info), nil
|
return toProtocolSignatureHelp(info), nil
|
||||||
}
|
}
|
||||||
|
@ -483,17 +483,14 @@ func (s *Server) DocumentHighlight(ctx context.Context, params *protocol.TextDoc
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
spn, err := m.PointSpan(params.Position)
|
spn, err := m.PointSpan(params.Position)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rng, err := spn.Range(m.Converter)
|
rng, err := spn.Range(m.Converter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
spans := source.Highlight(ctx, f, rng.Start)
|
spans := source.Highlight(ctx, f, rng.Start)
|
||||||
return toProtocolHighlight(m, spans), nil
|
return toProtocolHighlight(m, spans), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func toProtocolSignatureHelp(info *source.SignatureInformation) *protocol.SignatureHelp {
|
func toProtocolSignatureHelp(info *source.SignatureInformation) *protocol.SignatureHelp {
|
||||||
|
if info == nil {
|
||||||
|
return &protocol.SignatureHelp{}
|
||||||
|
}
|
||||||
return &protocol.SignatureHelp{
|
return &protocol.SignatureHelp{
|
||||||
ActiveParameter: float64(info.ActiveParameter),
|
ActiveParameter: float64(info.ActiveParameter),
|
||||||
ActiveSignature: 0, // there is only ever one possible signature
|
ActiveSignature: 0, // there is only ever one possible signature
|
||||||
|
|
Loading…
Reference in New Issue