From 379209517ffe9b1ca12ec8db6abe90d4a6605675 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Tue, 5 Feb 2019 14:22:07 -0500 Subject: [PATCH] internal/lsp: add additional logging for go/packages failures Change-Id: I8c6dae4309df1746cd8b74d280f1f360f42cc77b Reviewed-on: https://go-review.googlesource.com/c/161218 Reviewed-by: Ian Cottrell --- internal/lsp/cache/view.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/lsp/cache/view.go b/internal/lsp/cache/view.go index 8c05f45a3f2..a9f0ab1c17c 100644 --- a/internal/lsp/cache/view.go +++ b/internal/lsp/cache/view.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "go/token" + "log" "sync" "golang.org/x/tools/go/packages" @@ -112,7 +113,15 @@ func (v *View) parse(uri source.URI) error { // Add every file in this package to our cache. for _, fAST := range pkg.Syntax { // TODO: If a file is in multiple packages, which package do we store? + if !fAST.Pos().IsValid() { + log.Printf("invalid position for AST %v", fAST.Name) + continue + } fToken := v.Config.Fset.File(fAST.Pos()) + if fToken == nil { + log.Printf("no token.File for %v", fAST.Name) + continue + } fURI := source.ToURI(fToken.Name()) f := v.getFile(fURI) f.token = fToken