internal/lsp: add check for nil package

Fixes golang/go#31604

Change-Id: I60ec000d505c64783e5f51f62d168dc31c2fbe19
Reviewed-on: https://go-review.googlesource.com/c/tools/+/172968
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-04-22 12:49:04 -04:00
parent 1e2181f3f4
commit 3ff669b183
1 changed files with 3 additions and 0 deletions

View File

@ -54,6 +54,9 @@ func Identifier(ctx context.Context, v View, f File, pos token.Pos) (*Identifier
func identifier(ctx context.Context, v View, f File, pos token.Pos) (*IdentifierInfo, error) { func identifier(ctx context.Context, v View, f File, pos token.Pos) (*IdentifierInfo, error) {
fAST := f.GetAST(ctx) fAST := f.GetAST(ctx)
pkg := f.GetPackage(ctx) pkg := f.GetPackage(ctx)
if pkg == nil {
return nil, fmt.Errorf("no package for %s", f.URI())
}
if pkg.IsIllTyped() { if pkg.IsIllTyped() {
return nil, fmt.Errorf("package for %s is ill typed", f.URI()) return nil, fmt.Errorf("package for %s is ill typed", f.URI())
} }