mirror of
https://github.com/golang/go
synced 2024-11-18 16:14:46 -07:00
internal/lsp: label context cancellation errors
This change will just make it a bit easier to debug the context cancellation errors. Change-Id: I580751ac04e3357031678eb31914828029c96e4b Reviewed-on: https://go-review.googlesource.com/c/tools/+/190412 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
922a4ee32d
commit
3100af0b0e
2
internal/lsp/cache/check.go
vendored
2
internal/lsp/cache/check.go
vendored
@ -128,7 +128,7 @@ func (cph *checkPackageHandle) Check(ctx context.Context) (source.Package, error
|
||||
func (cph *checkPackageHandle) check(ctx context.Context) (*pkg, error) {
|
||||
v := cph.handle.Get(ctx)
|
||||
if v == nil {
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("check: %v", ctx.Err())
|
||||
}
|
||||
data := v.(*checkPackageData)
|
||||
return data.pkg, data.err
|
||||
|
2
internal/lsp/cache/load.go
vendored
2
internal/lsp/cache/load.go
vendored
@ -80,7 +80,7 @@ func (v *view) checkMetadata(ctx context.Context, f *goFile) (map[packageID]*met
|
||||
|
||||
// Check if the context has been canceled before calling packages.Load.
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("checkMetadata: %v", ctx.Err())
|
||||
}
|
||||
|
||||
ctx, done := trace.StartSpan(ctx, "packages.Load", telemetry.File.Of(f.filename()))
|
||||
|
2
internal/lsp/cache/parse.go
vendored
2
internal/lsp/cache/parse.go
vendored
@ -70,7 +70,7 @@ func (h *parseGoHandle) Mode() source.ParseMode {
|
||||
func (h *parseGoHandle) Parse(ctx context.Context) (*ast.File, error) {
|
||||
v := h.handle.Get(ctx)
|
||||
if v == nil {
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("Parse: %v", ctx.Err())
|
||||
}
|
||||
data := v.(*parseGoData)
|
||||
return data.ast, data.err
|
||||
|
7
internal/lsp/cache/pkg.go
vendored
7
internal/lsp/cache/pkg.go
vendored
@ -14,6 +14,7 @@ import (
|
||||
"golang.org/x/tools/go/analysis"
|
||||
"golang.org/x/tools/go/packages"
|
||||
"golang.org/x/tools/internal/lsp/source"
|
||||
errors "golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
// pkg contains the type information needed by the source package.
|
||||
@ -55,10 +56,6 @@ type analysisEntry struct {
|
||||
}
|
||||
|
||||
func (pkg *pkg) GetActionGraph(ctx context.Context, a *analysis.Analyzer) (*source.Action, error) {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
|
||||
pkg.mu.Lock()
|
||||
e, ok := pkg.analyses[a]
|
||||
if ok {
|
||||
@ -75,7 +72,7 @@ func (pkg *pkg) GetActionGraph(ctx context.Context, a *analysis.Analyzer) (*sour
|
||||
return pkg.GetActionGraph(ctx, a)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("GetActionGraph: %v", ctx.Err())
|
||||
}
|
||||
} else {
|
||||
// cache miss
|
||||
|
2
internal/lsp/cache/token.go
vendored
2
internal/lsp/cache/token.go
vendored
@ -51,7 +51,7 @@ func (h *tokenHandle) File() source.FileHandle {
|
||||
func (h *tokenHandle) Token(ctx context.Context) (*token.File, error) {
|
||||
v := h.handle.Get(ctx)
|
||||
if v == nil {
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("Token: %v", ctx.Err())
|
||||
}
|
||||
data := v.(*tokenData)
|
||||
return data.tok, data.err
|
||||
|
@ -26,8 +26,9 @@ import (
|
||||
func analyze(ctx context.Context, v View, cphs []CheckPackageHandle, analyzers []*analysis.Analyzer) ([]*Action, error) {
|
||||
ctx, done := trace.StartSpan(ctx, "source.analyze")
|
||||
defer done()
|
||||
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
return nil, errors.Errorf("analyze: %v", ctx.Err())
|
||||
}
|
||||
|
||||
// Build nodes for initial packages.
|
||||
|
Loading…
Reference in New Issue
Block a user