mirror of
https://github.com/golang/go
synced 2024-11-18 10:04:43 -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:
parent
aa3d50130b
commit
4bdfe1a3b7
14
internal/lsp/cache/cache.go
vendored
14
internal/lsp/cache/cache.go
vendored
@ -176,11 +176,21 @@ func (c *Cache) PackageStats(withNames bool) template.HTML {
|
|||||||
switch k.(type) {
|
switch k.(type) {
|
||||||
case packageHandleKey:
|
case packageHandleKey:
|
||||||
v := v.(*packageData)
|
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{
|
stat := packageStat{
|
||||||
id: v.pkg.id,
|
id: v.pkg.id,
|
||||||
mode: v.pkg.mode,
|
mode: v.pkg.mode,
|
||||||
types: typesCost(v.pkg.types.Scope()),
|
types: typsCost,
|
||||||
typesInfo: typesInfoCost(v.pkg.typesInfo),
|
typesInfo: typInfoCost,
|
||||||
}
|
}
|
||||||
for _, f := range v.pkg.compiledGoFiles {
|
for _, f := range v.pkg.compiledGoFiles {
|
||||||
fvi := f.handle.Cached()
|
fvi := f.handle.Cached()
|
||||||
|
Loading…
Reference in New Issue
Block a user