internal/lsp/cache: keep going on failed analyzers

A single failed analyzer should not prevent others from reporting their
diagnostics. This is especially relevant as we work on updating
analyzers to support generic code.

Change-Id: If1d958347649a99df92701fc4a4574cb7020596b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/351550
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Robert Findley 2021-09-22 12:11:20 -04:00
parent 284795867f
commit c8db761657
1 changed files with 3 additions and 1 deletions

View File

@ -46,7 +46,9 @@ func (s *snapshot) Analyze(ctx context.Context, id string, analyzers []*source.A
for _, ah := range roots {
diagnostics, _, err := ah.analyze(ctx, s)
if err != nil {
return nil, err
// Keep going if a single analyzer failed.
event.Error(ctx, fmt.Sprintf("analyzer %q failed", ah.analyzer.Name), err)
continue
}
results = append(results, diagnostics...)
}