@@ -101,7 +101,7 @@ type snapshot struct {
101101
102102 // symbolizeHandles maps each file URI to a handle for the future
103103 // result of computing the symbols declared in that file.
104- symbolizeHandles * persistent.Map // from span.URI to *memoize.Promise[symbolizeResult]
104+ symbolizeHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[symbolizeResult]
105105
106106 // packages maps a packageKey to a *packageHandle.
107107 // It may be invalidated when a file's content changes.
@@ -110,13 +110,13 @@ type snapshot struct {
110110 // - packages.Get(id).meta == meta.metadata[id] for all ids
111111 // - if a package is in packages, then all of its dependencies should also
112112 // be in packages, unless there is a missing import
113- packages * persistent.Map // from packageID to *packageHandle
113+ packages * persistent.Map [ PackageID , * packageHandle ]
114114
115115 // activePackages maps a package ID to a memoized active package, or nil if
116116 // the package is known not to be open.
117117 //
118118 // IDs not contained in the map are not known to be open or not open.
119- activePackages * persistent.Map // from packageID to *Package
119+ activePackages * persistent.Map [ PackageID , * Package ]
120120
121121 // workspacePackages contains the workspace's packages, which are loaded
122122 // when the view is created. It contains no intermediate test variants.
@@ -137,18 +137,18 @@ type snapshot struct {
137137
138138 // parseModHandles keeps track of any parseModHandles for the snapshot.
139139 // The handles need not refer to only the view's go.mod file.
140- parseModHandles * persistent.Map // from span.URI to *memoize.Promise[parseModResult]
140+ parseModHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[parseModResult]
141141
142142 // parseWorkHandles keeps track of any parseWorkHandles for the snapshot.
143143 // The handles need not refer to only the view's go.work file.
144- parseWorkHandles * persistent.Map // from span.URI to *memoize.Promise[parseWorkResult]
144+ parseWorkHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[parseWorkResult]
145145
146146 // Preserve go.mod-related handles to avoid garbage-collecting the results
147147 // of various calls to the go command. The handles need not refer to only
148148 // the view's go.mod file.
149- modTidyHandles * persistent.Map // from span.URI to *memoize.Promise[modTidyResult]
150- modWhyHandles * persistent.Map // from span.URI to *memoize.Promise[modWhyResult]
151- modVulnHandles * persistent.Map // from span.URI to *memoize.Promise[modVulnResult]
149+ modTidyHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[modTidyResult]
150+ modWhyHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[modWhyResult]
151+ modVulnHandles * persistent.Map [ span.URI , * memoize. Promise ] // *memoize.Promise[modVulnResult]
152152
153153 // knownSubdirs is the set of subdirectory URIs in the workspace,
154154 // used to create glob patterns for file watching.
@@ -871,7 +871,7 @@ func (s *snapshot) getActivePackage(id PackageID) *Package {
871871 defer s .mu .Unlock ()
872872
873873 if value , ok := s .activePackages .Get (id ); ok {
874- return value .( * Package ) // possibly nil, if we have already checked this id.
874+ return value
875875 }
876876 return nil
877877}
@@ -895,7 +895,7 @@ func (s *snapshot) setActivePackage(id PackageID, pkg *Package) {
895895
896896func (s * snapshot ) resetActivePackagesLocked () {
897897 s .activePackages .Destroy ()
898- s .activePackages = persistent .NewMap ( packageIDLessInterface )
898+ s .activePackages = new ( persistent.Map [ PackageID , * Package ] )
899899}
900900
901901const fileExtensions = "go,mod,sum,work"
@@ -2189,7 +2189,7 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
21892189 result .packages .Delete (id )
21902190 } else {
21912191 if entry , hit := result .packages .Get (id ); hit {
2192- ph := entry .( * packageHandle ). clone (false )
2192+ ph := entry .clone (false )
21932193 result .packages .Set (id , ph , nil )
21942194 }
21952195 }
@@ -2291,12 +2291,11 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
22912291// changed that happens not to be present in the map, but that's OK: the goal
22922292// of this function is to guarantee that IF the nearest mod file is present in
22932293// the map, it is invalidated.
2294- func deleteMostRelevantModFile (m * persistent.Map , changed span.URI ) {
2294+ func deleteMostRelevantModFile (m * persistent.Map [span. URI , * memoize. Promise ] , changed span.URI ) {
22952295 var mostRelevant span.URI
22962296 changedFile := changed .Filename ()
22972297
2298- m .Range (func (key , value interface {}) {
2299- modURI := key .(span.URI )
2298+ m .Range (func (modURI span.URI , _ * memoize.Promise ) {
23002299 if len (modURI ) > len (mostRelevant ) {
23012300 if source .InDir (filepath .Dir (modURI .Filename ()), changedFile ) {
23022301 mostRelevant = modURI
0 commit comments