internal/lsp: handle nil pointer in PackageStats

Fixes golang/go#40224

Change-Id: I9f3f194b1c115ff0242cbce89a36e20d9e21a41f
Reviewed-on: https://go-review.googlesource.com/c/tools/+/242797
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-07-15 13:13:59 -04:00
parent b42590c1b1
commit 4cea89713c
1 changed files with 3 additions and 0 deletions

View File

@ -236,6 +236,9 @@ func (c *Cache) PackageStats(withNames bool) template.HTML {
}
func astCost(f *ast.File) int64 {
if f == nil {
return 0
}
var count int64
ast.Inspect(f, func(n ast.Node) bool {
count += 32 // nodes are pretty small.