Skip to content

Commit 2c78df6

Browse files
committed
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Cottrell <[email protected]>
1 parent 26647e3 commit 2c78df6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

internal/lsp/cache/file.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func (f *goFile) GetToken(ctx context.Context) *token.File {
8989
defer f.view.mu.Unlock()
9090
if f.token == nil || len(f.view.contentChanges) > 0 {
9191
if _, err := f.view.parse(ctx, f); err != nil {
92+
f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err)
9293
return nil
9394
}
9495
}
@@ -101,6 +102,7 @@ func (f *goFile) GetAST(ctx context.Context) *ast.File {
101102

102103
if f.ast == nil || len(f.view.contentChanges) > 0 {
103104
if _, err := f.view.parse(ctx, f); err != nil {
105+
f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err)
104106
return nil
105107
}
106108
}
@@ -113,6 +115,8 @@ func (f *goFile) GetPackage(ctx context.Context) source.Package {
113115

114116
if f.pkg == nil || len(f.view.contentChanges) > 0 {
115117
if errs, err := f.view.parse(ctx, f); err != nil {
118+
f.View().Session().Logger().Errorf(ctx, "unable to check package for %s: %v", f.URI(), err)
119+
116120
// Create diagnostics for errors if we are able to.
117121
if len(errs) > 0 {
118122
return &pkg{errors: errs}

internal/lsp/info.1.11.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import (
1212
)
1313

1414
func printBuildInfo(w io.Writer, verbose bool) {
15-
fmt.Fprintf(w, "no module information, gopls not build with go 1.11 or earlier\n")
15+
fmt.Fprintf(w, "no module information, gopls not built with go 1.11 or earlier\n")
1616
}

0 commit comments

Comments
 (0)