mirror of https://github.com/golang/go.git
internal/lsp/cache: keep going on per-file workspace symbol errors
I'm not sure how to hit this in practice, since it appears that symbols should only return errors with some type of corruption, but we should keep going when searching for symbols in snapshot files. Change-Id: I9fcf6cc92fdc943520e8890ece51d28ec46e8812 Reviewed-on: https://go-review.googlesource.com/c/tools/+/376363 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Peter Weinberger <pjw@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
21ca3b3a93
commit
6299a6dbc2
|
|
@ -966,15 +966,25 @@ func (s *snapshot) activePackageHandles(ctx context.Context) ([]*packageHandle,
|
|||
|
||||
func (s *snapshot) Symbols(ctx context.Context) (map[span.URI][]source.Symbol, error) {
|
||||
result := make(map[span.URI][]source.Symbol)
|
||||
|
||||
// Keep going on errors, but log the first failure. Partial symbol results
|
||||
// are better than no symbol results.
|
||||
var firstErr error
|
||||
for uri, f := range s.files {
|
||||
sh := s.buildSymbolHandle(ctx, f)
|
||||
v, err := sh.handle.Get(ctx, s.generation, s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
if firstErr == nil {
|
||||
firstErr = err
|
||||
}
|
||||
continue
|
||||
}
|
||||
data := v.(*symbolData)
|
||||
result[uri] = data.symbols
|
||||
}
|
||||
if firstErr != nil {
|
||||
event.Error(ctx, "getting snapshot symbols", firstErr)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue