From 2c78df6d2ceec2cde4b7bff46c9b42cd05742fe1 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Mon, 20 May 2019 18:44:24 -0400 Subject: [PATCH] internal/lsp: log when we fail to type-check a package Change-Id: I07a0a224359b698e50da8496b21634d8bd947aa9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/178277 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/cache/file.go | 4 ++++ internal/lsp/info.1.11.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/lsp/cache/file.go b/internal/lsp/cache/file.go index bd8fb054c2..14bb7f54e8 100644 --- a/internal/lsp/cache/file.go +++ b/internal/lsp/cache/file.go @@ -89,6 +89,7 @@ func (f *goFile) GetToken(ctx context.Context) *token.File { defer f.view.mu.Unlock() if f.token == nil || len(f.view.contentChanges) > 0 { if _, err := f.view.parse(ctx, f); err != nil { + f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err) return nil } } @@ -101,6 +102,7 @@ func (f *goFile) GetAST(ctx context.Context) *ast.File { if f.ast == nil || len(f.view.contentChanges) > 0 { if _, err := f.view.parse(ctx, f); err != nil { + f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err) return nil } } @@ -113,6 +115,8 @@ func (f *goFile) GetPackage(ctx context.Context) source.Package { if f.pkg == nil || len(f.view.contentChanges) > 0 { if errs, err := f.view.parse(ctx, f); err != nil { + f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err) + // Create diagnostics for errors if we are able to. if len(errs) > 0 { return &pkg{errors: errs} diff --git a/internal/lsp/info.1.11.go b/internal/lsp/info.1.11.go index cd243393fd..ac4128f0a3 100644 --- a/internal/lsp/info.1.11.go +++ b/internal/lsp/info.1.11.go @@ -12,5 +12,5 @@ import ( ) func printBuildInfo(w io.Writer, verbose bool) { - fmt.Fprintf(w, "no module information, gopls not build with go 1.11 or earlier\n") + fmt.Fprintf(w, "no module information, gopls not built with go 1.11 or earlier\n") }