Skip to content

Commit

Permalink
internal/lsp/cache: handle a few possible panics in PackageStats
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 4bdfe1a)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/240542
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
stamblerre committed Jun 30, 2020
1 parent cbc3639 commit 24ca011
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/lsp/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 24ca011

Please sign in to comment.