Skip to content

Commit 99fd76f

Browse files
committed
internal/lsp/cache: delete KnownMetadata.PkgFilesChanged
It is no longer needed, now that we don't consider invalid packages to be workspace packages. Change-Id: I6155a2609ab07046b9507dc04717eea7b974f1b6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/421257 gopls-CI: kokoro <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Robert Findley <[email protected]>
1 parent 01c9ff0 commit 99fd76f

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

internal/lsp/cache/load.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -644,16 +644,6 @@ func computeWorkspacePackagesLocked(s *snapshot, meta *metadataGraph) map[Packag
644644
if !containsPackageLocked(s, m.Metadata) {
645645
continue
646646
}
647-
if m.PkgFilesChanged {
648-
// If a package name has changed, it's possible that the package no
649-
// longer exists. Leaving it as a workspace package can result in
650-
// persistent stale diagnostics.
651-
//
652-
// If there are still valid files in the package, it will be reloaded.
653-
//
654-
// There may be more precise heuristics.
655-
continue
656-
}
657647

658648
if source.IsCommandLineArguments(string(m.ID)) {
659649
// If all the files contained in m have a real package, we don't need to

internal/lsp/cache/metadata.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,4 @@ type KnownMetadata struct {
9191
// Valid is true if the given metadata is Valid.
9292
// Invalid metadata can still be used if a metadata reload fails.
9393
Valid bool
94-
95-
// PkgFilesChanged reports whether the file set of this metadata has
96-
// potentially changed.
97-
//
98-
// TODO(rfindley): this is used for WorkspacePackages, and looks fishy: we
99-
// should probably only consider valid packages to be workspace packages.
100-
PkgFilesChanged bool
10194
}

internal/lsp/cache/snapshot.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,10 +1734,9 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
17341734
}
17351735

17361736
// Compute invalidations based on file changes.
1737-
changedPkgFiles := map[PackageID]bool{} // packages whose file set may have changed
1738-
anyImportDeleted := false // import deletions can resolve cycles
1739-
anyFileOpenedOrClosed := false // opened files affect workspace packages
1740-
anyFileAdded := false // adding a file can resolve missing dependencies
1737+
anyImportDeleted := false // import deletions can resolve cycles
1738+
anyFileOpenedOrClosed := false // opened files affect workspace packages
1739+
anyFileAdded := false // adding a file can resolve missing dependencies
17411740

17421741
for uri, change := range changes {
17431742
// The original FileHandle for this URI is cached on the snapshot.
@@ -1762,11 +1761,6 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
17621761

17631762
// Mark all of the package IDs containing the given file.
17641763
filePackageIDs := invalidatedPackageIDs(uri, s.meta.ids, pkgFileChanged)
1765-
if pkgFileChanged {
1766-
for id := range filePackageIDs {
1767-
changedPkgFiles[id] = true
1768-
}
1769-
}
17701764
for id := range filePackageIDs {
17711765
directIDs[id] = directIDs[id] || invalidateMetadata
17721766
}
@@ -1953,13 +1947,11 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
19531947

19541948
// Check if the metadata has changed.
19551949
valid := v.Valid && !invalidateMetadata
1956-
pkgFilesChanged := v.PkgFilesChanged || changedPkgFiles[k]
1957-
if valid != v.Valid || pkgFilesChanged != v.PkgFilesChanged {
1950+
if valid != v.Valid {
19581951
// Mark invalidated metadata rather than deleting it outright.
19591952
metadataUpdates[k] = &KnownMetadata{
1960-
Metadata: v.Metadata,
1961-
Valid: valid,
1962-
PkgFilesChanged: pkgFilesChanged,
1953+
Metadata: v.Metadata,
1954+
Valid: valid,
19631955
}
19641956
}
19651957
}

0 commit comments

Comments
 (0)