mirror of
https://github.com/golang/go
synced 2024-11-18 17:04:41 -07:00
internal/lsp/cache: avoid returning errors when building source.Errors
We don't want to return an error for the whole package when we are just building out error positions. Change-Id: I56b5b88ff2b4b44da8a372ade81cd9b1534235c4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/206597 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
9d59ce8a7f
commit
52adfe5cb6
3
internal/lsp/cache/check.go
vendored
3
internal/lsp/cache/check.go
vendored
@ -310,7 +310,8 @@ func typeCheck(ctx context.Context, fset *token.FileSet, m *metadata, mode sourc
|
||||
for _, e := range rawErrors {
|
||||
srcErr, err := sourceError(ctx, fset, pkg, e)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(ctx, "unable to compute error positions", err, telemetry.Package.Of(pkg.ID()))
|
||||
continue
|
||||
}
|
||||
pkg.errors = append(pkg.errors, srcErr)
|
||||
}
|
||||
|
9
internal/lsp/cache/errors.go
vendored
9
internal/lsp/cache/errors.go
vendored
@ -12,7 +12,9 @@ import (
|
||||
"golang.org/x/tools/go/packages"
|
||||
"golang.org/x/tools/internal/lsp/protocol"
|
||||
"golang.org/x/tools/internal/lsp/source"
|
||||
"golang.org/x/tools/internal/lsp/telemetry"
|
||||
"golang.org/x/tools/internal/span"
|
||||
"golang.org/x/tools/internal/telemetry/log"
|
||||
errors "golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
@ -40,7 +42,8 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface
|
||||
kind = source.ParseError
|
||||
spn, err = scannerErrorRange(ctx, fset, pkg, e.Pos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(ctx, "no span for scanner.Error pos", err, telemetry.Package.Of(pkg.ID()))
|
||||
spn = span.Parse(e.Pos.String())
|
||||
}
|
||||
|
||||
case scanner.ErrorList:
|
||||
@ -52,9 +55,9 @@ func sourceError(ctx context.Context, fset *token.FileSet, pkg *pkg, e interface
|
||||
kind = source.ParseError
|
||||
spn, err = scannerErrorRange(ctx, fset, pkg, e[0].Pos)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
log.Error(ctx, "no span for scanner.Error pos", err, telemetry.Package.Of(pkg.ID()))
|
||||
spn = span.Parse(e[0].Pos.String())
|
||||
}
|
||||
|
||||
case types.Error:
|
||||
msg = e.Msg
|
||||
kind = source.TypeError
|
||||
|
Loading…
Reference in New Issue
Block a user