From c8db76165785717f38f6e82eb659e5aae5e991da Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Wed, 22 Sep 2021 12:11:20 -0400 Subject: [PATCH] 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 Run-TryBot: Robert Findley gopls-CI: kokoro TryBot-Result: Go Bot Reviewed-by: Rebecca Stambler --- internal/lsp/cache/analysis.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/lsp/cache/analysis.go b/internal/lsp/cache/analysis.go index baaad5af67a..c4b74407ab0 100644 --- a/internal/lsp/cache/analysis.go +++ b/internal/lsp/cache/analysis.go @@ -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...) }