1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

internal/lsp/cache: handle a few possible panics in PackageStats

Change-Id: I50dbe8bf7d801e7325bdbe413368e85779511d85
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240183
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-06-26 17:18:10 -04:00
parent aa3d50130b
commit 4bdfe1a3b7

View File

@ -176,11 +176,21 @@ func (c *Cache) PackageStats(withNames bool) template.HTML {
switch k.(type) {
case packageHandleKey:
v := v.(*packageData)
if v.pkg == nil {
break
}
var typsCost, typInfoCost int64
if v.pkg.types != nil {
typsCost = typesCost(v.pkg.types.Scope())
}
if v.pkg.typesInfo != nil {
typInfoCost = typesInfoCost(v.pkg.typesInfo)
}
stat := packageStat{
id: v.pkg.id,
mode: v.pkg.mode,
types: typesCost(v.pkg.types.Scope()),
typesInfo: typesInfoCost(v.pkg.typesInfo),
types: typsCost,
typesInfo: typInfoCost,
}
for _, f := range v.pkg.compiledGoFiles {
fvi := f.handle.Cached()