From 607ca053a1376e059c47e49108c4656de7934535 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Sun, 14 Jul 2019 14:54:41 -0400 Subject: [PATCH] internal/lsp: fix panics in loading, add more logging Fixes golang/go#32929 Change-Id: I15e258fe03ef07dbb4ece79f52cb0d0353c8b0b1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/185994 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/cache/load.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index f0e4bbbd..d0c2b1db 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -100,7 +100,10 @@ func (v *view) checkMetadata(ctx context.Context, f *goFile) (map[packageID]*met } // Track missing imports as we look at the package's errors. missingImports := make(map[packagePath]struct{}) + + xlog.Debugf(ctx, "packages.Load: found %v packages", len(pkgs)) for _, pkg := range pkgs { + xlog.Debugf(ctx, "packages.Load: package %s with files %v", pkg.PkgPath, pkg.CompiledGoFiles) // If the package comes back with errors from `go list`, // don't bother type-checking it. if len(pkg.Errors) > 0 { @@ -226,10 +229,12 @@ func (v *view) link(ctx context.Context, pkgPath packagePath, pkg *packages.Pack f, err := v.getFile(ctx, span.FileURI(filename)) if err != nil { xlog.Errorf(ctx, "no file %s: %v", filename, err) + continue } gof, ok := f.(*goFile) if !ok { xlog.Errorf(ctx, "not a Go file: %s", f.URI()) + continue } if gof.meta == nil { gof.meta = make(map[packageID]*metadata)