@@ -101,7 +101,7 @@ type snapshot struct {
101
101
102
102
// symbolizeHandles maps each file URI to a handle for the future
103
103
// 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]
105
105
106
106
// packages maps a packageKey to a *packageHandle.
107
107
// It may be invalidated when a file's content changes.
@@ -110,13 +110,13 @@ type snapshot struct {
110
110
// - packages.Get(id).meta == meta.metadata[id] for all ids
111
111
// - if a package is in packages, then all of its dependencies should also
112
112
// be in packages, unless there is a missing import
113
- packages * persistent.Map // from packageID to *packageHandle
113
+ packages * persistent.Map [ PackageID , * packageHandle ]
114
114
115
115
// activePackages maps a package ID to a memoized active package, or nil if
116
116
// the package is known not to be open.
117
117
//
118
118
// 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 ]
120
120
121
121
// workspacePackages contains the workspace's packages, which are loaded
122
122
// when the view is created. It contains no intermediate test variants.
@@ -137,18 +137,18 @@ type snapshot struct {
137
137
138
138
// parseModHandles keeps track of any parseModHandles for the snapshot.
139
139
// 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]
141
141
142
142
// parseWorkHandles keeps track of any parseWorkHandles for the snapshot.
143
143
// 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]
145
145
146
146
// Preserve go.mod-related handles to avoid garbage-collecting the results
147
147
// of various calls to the go command. The handles need not refer to only
148
148
// 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]
152
152
153
153
// knownSubdirs is the set of subdirectory URIs in the workspace,
154
154
// used to create glob patterns for file watching.
@@ -871,7 +871,7 @@ func (s *snapshot) getActivePackage(id PackageID) *Package {
871
871
defer s .mu .Unlock ()
872
872
873
873
if value , ok := s .activePackages .Get (id ); ok {
874
- return value .( * Package ) // possibly nil, if we have already checked this id.
874
+ return value
875
875
}
876
876
return nil
877
877
}
@@ -895,7 +895,7 @@ func (s *snapshot) setActivePackage(id PackageID, pkg *Package) {
895
895
896
896
func (s * snapshot ) resetActivePackagesLocked () {
897
897
s .activePackages .Destroy ()
898
- s .activePackages = persistent .NewMap ( packageIDLessInterface )
898
+ s .activePackages = new ( persistent.Map [ PackageID , * Package ] )
899
899
}
900
900
901
901
const fileExtensions = "go,mod,sum,work"
@@ -2189,7 +2189,7 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
2189
2189
result .packages .Delete (id )
2190
2190
} else {
2191
2191
if entry , hit := result .packages .Get (id ); hit {
2192
- ph := entry .( * packageHandle ). clone (false )
2192
+ ph := entry .clone (false )
2193
2193
result .packages .Set (id , ph , nil )
2194
2194
}
2195
2195
}
@@ -2291,12 +2291,11 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
2291
2291
// changed that happens not to be present in the map, but that's OK: the goal
2292
2292
// of this function is to guarantee that IF the nearest mod file is present in
2293
2293
// 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 ) {
2295
2295
var mostRelevant span.URI
2296
2296
changedFile := changed .Filename ()
2297
2297
2298
- m .Range (func (key , value interface {}) {
2299
- modURI := key .(span.URI )
2298
+ m .Range (func (modURI span.URI , _ * memoize.Promise ) {
2300
2299
if len (modURI ) > len (mostRelevant ) {
2301
2300
if source .InDir (filepath .Dir (modURI .Filename ()), changedFile ) {
2302
2301
mostRelevant = modURI
0 commit comments