1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:14:46 -07:00

internal/lsp: return context cancellation from LookupBuiltin

Change-Id: If90d111fbe89d2be445b15ec3721d48280540de9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/216305
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
Rebecca Stambler 2020-01-24 17:08:04 -05:00
parent 73c4c875f0
commit bcecb1fcc1
2 changed files with 6 additions and 1 deletions

View File

@ -204,6 +204,9 @@ func (v *view) LookupBuiltin(ctx context.Context, name string) (*ast.Object, err
return nil, err
}
data := v.builtin.handle.Get(ctx)
if ctx.Err() != nil {
return nil, ctx.Err()
}
if data == nil {
return nil, errors.Errorf("unexpected nil builtin package")
}

View File

@ -246,7 +246,9 @@ func (c *completer) formatBuiltin(cand candidate) CompletionItem {
item.Kind = protocol.FunctionCompletion
astObj, err := c.snapshot.View().LookupBuiltin(c.ctx, obj.Name())
if err != nil {
log.Error(c.ctx, "no builtin package", err)
if c.ctx.Err() == nil {
log.Error(c.ctx, "no builtin package", err)
}
break
}
decl, ok := astObj.Decl.(*ast.FuncDecl)