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:
parent
191e9ce6ac
commit
8bdde6d5f2
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue