internal/lsp: clear out missing imports set when we re-load package

This change ensures that we always populate a new set of missing imports
when we re-load a package. Otherwise, we might keep stale missing
imports around.

Change-Id: Id9b6b8201e3ed093a7b9ece97a81e298de612a5e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/182459
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-06-14 14:10:39 -04:00
parent 1edc8e83c8
commit d1d6cdd8a6
1 changed files with 6 additions and 6 deletions

View File

@ -145,12 +145,11 @@ func (v *view) link(ctx context.Context, pkgPath packagePath, pkg *packages.Pack
// If we haven't seen this package before.
if !ok {
m = &metadata{
pkgPath: pkgPath,
id: id,
typesSizes: pkg.TypesSizes,
parents: make(map[packageID]bool),
children: make(map[packageID]bool),
missingImports: make(map[packagePath]struct{}),
pkgPath: pkgPath,
id: id,
typesSizes: pkg.TypesSizes,
parents: make(map[packageID]bool),
children: make(map[packageID]bool),
}
v.mcache.packages[id] = m
v.mcache.ids[pkgPath] = id
@ -172,6 +171,7 @@ func (v *view) link(ctx context.Context, pkgPath packagePath, pkg *packages.Pack
m.parents[parent.id] = true
parent.children[id] = true
}
m.missingImports = make(map[packagePath]struct{})
for importPath, importPkg := range pkg.Imports {
if len(importPkg.Errors) > 0 {
m.missingImports[pkgPath] = struct{}{}