@@ -2,7 +2,6 @@ package incremental
2
2
3
3
import (
4
4
"context"
5
- "iter"
6
5
"maps"
7
6
"slices"
8
7
"sync"
@@ -139,23 +138,14 @@ func (h *affectedFilesHandler) getFilesAffectedBy(path tspath.Path) []*ast.Sourc
139
138
})
140
139
}
141
140
142
- // Gets the files referenced by the the file path
143
- func (h * affectedFilesHandler ) getReferencedByPaths (file tspath.Path ) iter.Seq [tspath.Path ] {
144
- keys , ok := h .program .snapshot .referencedMap .GetKeys (file )
145
- if ! ok {
146
- return func (yield func (tspath.Path ) bool ) {}
147
- }
148
- return keys .Keys ()
149
- }
150
-
151
141
func (h * affectedFilesHandler ) forEachFileReferencedBy (file * ast.SourceFile , fn func (currentFile * ast.SourceFile , currentPath tspath.Path ) (queueForFile bool , fastReturn bool )) map [tspath.Path ]* ast.SourceFile {
152
142
// Now we need to if each file in the referencedBy list has a shape change as well.
153
143
// Because if so, its own referencedBy files need to be saved as well to make the
154
144
// emitting result consistent with files on disk.
155
145
seenFileNamesMap := map [tspath.Path ]* ast.SourceFile {}
156
146
// Start with the paths this file was referenced by
157
147
seenFileNamesMap [file .Path ()] = file
158
- queue := slices .Collect (h .getReferencedByPaths (file .Path ()))
148
+ queue := slices .Collect (h .program . snapshot . referencedMap . getReferencedBy (file .Path ()))
159
149
for len (queue ) > 0 {
160
150
currentPath := queue [len (queue )- 1 ]
161
151
queue = queue [:len (queue )- 1 ]
@@ -167,7 +157,7 @@ func (h *affectedFilesHandler) forEachFileReferencedBy(file *ast.SourceFile, fn
167
157
return seenFileNamesMap
168
158
}
169
159
if queueForFile {
170
- for ref := range h .getReferencedByPaths (currentFile .Path ()) {
160
+ for ref := range h .program . snapshot . referencedMap . getReferencedBy (currentFile .Path ()) {
171
161
queue = append (queue , ref )
172
162
}
173
163
}
@@ -253,18 +243,14 @@ func (h *affectedFilesHandler) handleDtsMayChangeOfAffectedFile(dtsMayChange dts
253
243
}
254
244
255
245
// Go through files that reference affected file and handle dts emit and semantic diagnostics for them and their references
256
- if keys , ok := h .program .snapshot .referencedMap .GetKeys (affectedFile .Path ()); ok {
257
- for exportedFromPath := range keys .Keys () {
258
- if h .handleDtsMayChangeOfGlobalScope (dtsMayChange , exportedFromPath , invalidateJsFiles ) {
246
+ for exportedFromPath := range h .program .snapshot .referencedMap .getReferencedBy (affectedFile .Path ()) {
247
+ if h .handleDtsMayChangeOfGlobalScope (dtsMayChange , exportedFromPath , invalidateJsFiles ) {
248
+ return
249
+ }
250
+ for filePath := range h .program .snapshot .referencedMap .getReferencedBy (exportedFromPath ) {
251
+ if h .handleDtsMayChangeOfFileAndExportsOfFile (dtsMayChange , filePath , invalidateJsFiles ) {
259
252
return
260
253
}
261
- if references , ok := h .program .snapshot .referencedMap .GetKeys (exportedFromPath ); ok {
262
- for filePath := range references .Keys () {
263
- if h .handleDtsMayChangeOfFileAndExportsOfFile (dtsMayChange , filePath , invalidateJsFiles ) {
264
- return
265
- }
266
- }
267
- }
268
254
}
269
255
}
270
256
}
@@ -279,11 +265,9 @@ func (h *affectedFilesHandler) handleDtsMayChangeOfFileAndExportsOfFile(dtsMayCh
279
265
h .handleDtsMayChangeOf (dtsMayChange , filePath , invalidateJsFiles )
280
266
281
267
// Remove the diagnostics of files that import this file and handle all its exports too
282
- if keys , ok := h .program .snapshot .referencedMap .GetKeys (filePath ); ok {
283
- for referencingFilePath := range keys .Keys () {
284
- if h .handleDtsMayChangeOfFileAndExportsOfFile (dtsMayChange , referencingFilePath , invalidateJsFiles ) {
285
- return true
286
- }
268
+ for referencingFilePath := range h .program .snapshot .referencedMap .getReferencedBy (filePath ) {
269
+ if h .handleDtsMayChangeOfFileAndExportsOfFile (dtsMayChange , referencingFilePath , invalidateJsFiles ) {
270
+ return true
287
271
}
288
272
}
289
273
return false
0 commit comments