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

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:
Rebecca Stambler 2019-04-09 07:22:09 +03:00
parent 9e5445377b
commit 96f2e7ef86
3 changed files with 6 additions and 5 deletions

View File

@ -33,7 +33,8 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara
}
items, prefix, err := source.Completion(ctx, f, rng.Start)
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{
IsIncomplete: false,

View File

@ -395,7 +395,7 @@ func (s *Server) SignatureHelp(ctx context.Context, params *protocol.TextDocumen
}
info, err := source.SignatureHelp(ctx, f, rng.Start)
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
}
@ -483,17 +483,14 @@ func (s *Server) DocumentHighlight(ctx context.Context, params *protocol.TextDoc
if err != nil {
return nil, err
}
spn, err := m.PointSpan(params.Position)
if err != nil {
return nil, err
}
rng, err := spn.Range(m.Converter)
if err != nil {
return nil, err
}
spans := source.Highlight(ctx, f, rng.Start)
return toProtocolHighlight(m, spans), nil
}

View File

@ -10,6 +10,9 @@ import (
)
func toProtocolSignatureHelp(info *source.SignatureInformation) *protocol.SignatureHelp {
if info == nil {
return &protocol.SignatureHelp{}
}
return &protocol.SignatureHelp{
ActiveParameter: float64(info.ActiveParameter),
ActiveSignature: 0, // there is only ever one possible signature