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:
parent
26647e34d3
commit
2c78df6d2c
4
internal/lsp/cache/file.go
vendored
4
internal/lsp/cache/file.go
vendored
@ -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}
|
||||
|
@ -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")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user