internal/lsp: re-run go/packages.Load when the package name changes

Fixes golang/go#32149

Change-Id: Ic02af6fd4fb19aae0d38a4d51ec4462abdc4f446
Reviewed-on: https://go-review.googlesource.com/c/tools/+/178162
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Rebecca Stambler 2019-05-21 14:14:29 -04:00
parent 7927dbab1b
commit 521d6ed310
1 changed files with 6 additions and 1 deletions

View File

@ -103,12 +103,17 @@ func (v *view) reparseImports(ctx context.Context, f *goFile, filename string) b
if f.meta == nil {
return true
}
// Get file content in case we don't already have it?
// Get file content in case we don't already have it.
f.read(ctx)
parsed, _ := parser.ParseFile(f.FileSet(), filename, f.content, parser.ImportsOnly)
if parsed == nil {
return true
}
// If the package name has changed, re-run `go list`.
if f.meta.name != parsed.Name.Name {
return true
}
// If the package's imports have changed, re-run `go list`.
if len(f.imports) != len(parsed.Imports) {
return true
}