internal/lsp: handle potential nil pointers in GetToken

Change-Id: Icd24c7c717099209f246fd4c0d5dc2e424613962
Reviewed-on: https://go-review.googlesource.com/c/tools/+/188757
Reviewed-by: Suzy Mueller <suzmue@golang.org>
diff --git a/internal/lsp/cache/gofile.go b/internal/lsp/cache/gofile.go
index a347a67..a376853 100644
--- a/internal/lsp/cache/gofile.go
+++ b/internal/lsp/cache/gofile.go
@@ -53,7 +53,11 @@
 	if file == nil {
 		return nil, err
 	}
-	return f.view.session.cache.fset.File(file.Pos()), nil
+	tok := f.view.session.cache.fset.File(file.Pos())
+	if tok == nil {
+		return nil, fmt.Errorf("no token.File for %s", f.URI())
+	}
+	return tok, nil
 }
 
 func (f *goFile) GetAST(ctx context.Context, mode source.ParseMode) (*ast.File, error) {