diff --git a/internal/lsp/cache/load.go b/internal/lsp/cache/load.go index 8afbb2e4ff..0952fc679b 100644 --- a/internal/lsp/cache/load.go +++ b/internal/lsp/cache/load.go @@ -644,16 +644,6 @@ func computeWorkspacePackagesLocked(s *snapshot, meta *metadataGraph) map[Packag if !containsPackageLocked(s, m.Metadata) { continue } - if m.PkgFilesChanged { - // If a package name has changed, it's possible that the package no - // longer exists. Leaving it as a workspace package can result in - // persistent stale diagnostics. - // - // If there are still valid files in the package, it will be reloaded. - // - // There may be more precise heuristics. - continue - } if source.IsCommandLineArguments(string(m.ID)) { // If all the files contained in m have a real package, we don't need to diff --git a/internal/lsp/cache/metadata.go b/internal/lsp/cache/metadata.go index 7d9192f43a..668d0829a1 100644 --- a/internal/lsp/cache/metadata.go +++ b/internal/lsp/cache/metadata.go @@ -91,11 +91,4 @@ type KnownMetadata struct { // Valid is true if the given metadata is Valid. // Invalid metadata can still be used if a metadata reload fails. Valid bool - - // PkgFilesChanged reports whether the file set of this metadata has - // potentially changed. - // - // TODO(rfindley): this is used for WorkspacePackages, and looks fishy: we - // should probably only consider valid packages to be workspace packages. - PkgFilesChanged bool } diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index 5a51ae13e0..da2d7b52e1 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -1734,10 +1734,9 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC } // Compute invalidations based on file changes. - changedPkgFiles := map[PackageID]bool{} // packages whose file set may have changed - anyImportDeleted := false // import deletions can resolve cycles - anyFileOpenedOrClosed := false // opened files affect workspace packages - anyFileAdded := false // adding a file can resolve missing dependencies + anyImportDeleted := false // import deletions can resolve cycles + anyFileOpenedOrClosed := false // opened files affect workspace packages + anyFileAdded := false // adding a file can resolve missing dependencies for uri, change := range changes { // 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 // Mark all of the package IDs containing the given file. filePackageIDs := invalidatedPackageIDs(uri, s.meta.ids, pkgFileChanged) - if pkgFileChanged { - for id := range filePackageIDs { - changedPkgFiles[id] = true - } - } for id := range filePackageIDs { directIDs[id] = directIDs[id] || invalidateMetadata } @@ -1953,13 +1947,11 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC // Check if the metadata has changed. valid := v.Valid && !invalidateMetadata - pkgFilesChanged := v.PkgFilesChanged || changedPkgFiles[k] - if valid != v.Valid || pkgFilesChanged != v.PkgFilesChanged { + if valid != v.Valid { // Mark invalidated metadata rather than deleting it outright. metadataUpdates[k] = &KnownMetadata{ - Metadata: v.Metadata, - Valid: valid, - PkgFilesChanged: pkgFilesChanged, + Metadata: v.Metadata, + Valid: valid, } } }