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 <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
This commit is contained in:
Rebecca Stambler 2019-02-20 15:36:48 -05:00
parent 191e9ce6ac
commit 8bdde6d5f2
2 changed files with 1 additions and 7 deletions

View File

@ -46,9 +46,7 @@ func (v *View) FileSet() *token.FileSet {
} }
func (v *View) GetAnalysisCache() *source.AnalysisCache { func (v *View) GetAnalysisCache() *source.AnalysisCache {
if v.analysisCache == nil { v.analysisCache = source.NewAnalysisCache()
v.analysisCache = source.NewAnalysisCache()
}
return v.analysisCache return v.analysisCache
} }

View File

@ -40,10 +40,6 @@ type analysisKey struct {
func (c *AnalysisCache) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action { func (c *AnalysisCache) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action {
// TODO(matloob): Every time but the first, this needs to re-construct // TODO(matloob): Every time but the first, this needs to re-construct
// the invalidated parts of the action graph, probably under a lock? // 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. // Construct the action graph.
var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *action var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *action