internal/lsp/cache: fix some package event tags

Package.ID() is far more useful to tag on events, as it disambiguates
multiple packages with the same path.

Change-Id: I03fd69f64641eb17155ca72ed2ef19641b75f004
Reviewed-on: https://go-review.googlesource.com/c/tools/+/279722
Run-TryBot: Robert Findley <rfindley@google.com>
Trust: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
Rob Findley 2020-12-23 13:41:09 -05:00 committed by Robert Findley
parent 9cbb1efa77
commit f6952e403d
3 changed files with 6 additions and 3 deletions

View File

@ -207,7 +207,7 @@ func runAnalysis(ctx context.Context, snapshot *snapshot, analyzer *analysis.Ana
}
defer func() {
if r := recover(); r != nil {
event.Log(ctx, fmt.Sprintf("analysis panicked: %s", r), tag.Package.Of(pkg.PkgPath()))
event.Log(ctx, fmt.Sprintf("analysis panicked: %s", r), tag.Package.Of(pkg.ID()))
data.err = errors.Errorf("analysis %s for package %s panicked: %v", analyzer.Name, pkg.PkgPath(), r)
}
}()

View File

@ -141,7 +141,10 @@ func (s *snapshot) load(ctx context.Context, allowNetwork bool, scopes ...interf
}
for _, pkg := range pkgs {
if !containsDir || s.view.Options().VerboseOutput {
event.Log(ctx, "go/packages.Load", tag.Snapshot.Of(s.ID()), tag.PackagePath.Of(pkg.PkgPath), tag.Files.Of(pkg.CompiledGoFiles))
event.Log(ctx, "go/packages.Load",
tag.Snapshot.Of(s.ID()),
tag.Package.Of(pkg.ID),
tag.Files.Of(pkg.CompiledGoFiles))
}
// Ignore packages with no sources, since we will never be able to
// correctly invalidate that metadata.

View File

@ -19,7 +19,7 @@ var (
File = keys.NewString("file", "")
Directory = keys.New("directory", "")
URI = keys.New("URI", "")
Package = keys.NewString("package", "")
Package = keys.NewString("package", "") // Package ID
PackagePath = keys.NewString("package_path", "")
Query = keys.New("query", "")
Snapshot = keys.NewUInt64("snapshot", "")