1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:04:42 -07:00

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 <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-05-20 18:44:24 -04:00
parent 26647e34d3
commit 2c78df6d2c
2 changed files with 5 additions and 1 deletions

View File

@ -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}

View File

@ -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")
}