Skip to content

Commit

Permalink
internal/lsp/cache: invalidate metadata for x_tests and test variants
Browse files Browse the repository at this point in the history
Invalidating metadata for reverse dependencies isn't necessary, except
for in the case of test variants and x_tests.

An example:

The only way to reload the metadata for
"golang.org/x/tools/internal/lsp/cache
[golang.org/x/tools/internal/lsp/source.test]" is by reloading
"golang.org/x/tools/internal/lsp/source" with "[-test -deps]". That
means we have to invalidate the metadata for that
"golang.org/x/tools/internal/lsp/source_test" when we invalidating
"golang.org/x/tools/internal/lsp/cache".

Fixes golang/go#36165

Change-Id: Iff0e03a7a46158fbdafaffa091f90ca434700a97
Reviewed-on: https://go-review.googlesource.com/c/tools/+/215117
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
  • Loading branch information
stamblerre committed Jan 17, 2020
1 parent ade7f25 commit 7ad9cd8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/lsp/cache/snapshot.go
Expand Up @@ -666,6 +666,22 @@ func (s *snapshot) clone(ctx context.Context, withoutURI span.URI) *snapshot {
for id := range directIDs {
addRevDeps(id)
}
// Invalidate metadata for the transitive dependencies,
// if they are x_tests and test variants.
//
// An example:
//
// The only way to reload the metadata for
// golang.org/x/tools/internal/lsp/cache [golang.org/x/tools/internal/lsp/source.test]
// is by reloading golang.org/x/tools/internal/lsp/source.
// That means we have to invalidate the metadata for
// golang.org/x/tools/internal/lsp/source_test when invalidating metadata for
// golang.org/x/tools/internal/lsp/cache.
for id := range transitiveIDs {
if m := s.metadata[id]; m != nil && m.forTest != "" {
directIDs[id] = struct{}{}
}
}

result := &snapshot{
id: s.id + 1,
Expand Down

0 comments on commit 7ad9cd8

Please sign in to comment.