internal/lsp/cache: add context cancellation check inside importerFunc

This change adds a check inside of the types.ImporterFunc to see if the context has been cancelled.

Updates golang/go#34683

Change-Id: I0f12da0f8158ecda0eec00150ed6ff772c2f89c3
Reviewed-on: https://go-review.googlesource.com/c/tools/+/217257
Run-TryBot: Rohan Challa <rohan@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rohan Challa 2020-01-31 13:15:27 -05:00
parent 97da75b46c
commit d6d1b0d853
1 changed files with 4 additions and 0 deletions

View File

@ -309,6 +309,10 @@ func typeCheck(ctx context.Context, fset *token.FileSet, m *metadata, mode sourc
rawErrors = append(rawErrors, e)
},
Importer: importerFunc(func(pkgPath string) (*types.Package, error) {
// If the context was cancelled, we should abort.
if ctx.Err() != nil {
return nil, ctx.Err()
}
dep := deps[packagePath(pkgPath)]
if dep == nil {
// We may be in GOPATH mode, in which case we need to check vendor dirs.