From 8bdde6d5f2ff06efe2259964b2d2065945d8516c Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Wed, 20 Feb 2019 15:36:48 -0500 Subject: [PATCH] internal/lsp: create new cache for each analysis Because diagnostics computations happen in parallel, we were getting concurrent map writes by keeping one cache. Change-Id: Ifa5adffe14c509168c9f8c5cb012f3fcd3a32441 Reviewed-on: https://go-review.googlesource.com/c/163161 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Michael Matloob --- internal/lsp/cache/view.go | 4 +--- internal/lsp/source/analysis.go | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index 22602b13..01b533c0 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -46,9 +46,7 @@ func (v *View) FileSet() *token.FileSet { } func (v *View) GetAnalysisCache() *source.AnalysisCache { - if v.analysisCache == nil { - v.analysisCache = source.NewAnalysisCache() - } + v.analysisCache = source.NewAnalysisCache() return v.analysisCache } diff --git a/internal/lsp/source/analysis.go b/internal/lsp/source/analysis.go index d01369c6..dacac7f3 100644 --- a/internal/lsp/source/analysis.go +++ b/internal/lsp/source/analysis.go @@ -40,10 +40,6 @@ type analysisKey struct { func (c *AnalysisCache) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action { // TODO(matloob): Every time but the first, this needs to re-construct // the invalidated parts of the action graph, probably under a lock? - // We'll take care of that later. For now, clear the entire cache! - for k := range c.m { - delete(c.m, k) - } // Construct the action graph. var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *action