@@ -96,7 +96,7 @@ package enum IndexTaskStatus: Comparable {
96
96
package enum IndexProgressStatus : Sendable {
97
97
case preparingFileForEditorFunctionality
98
98
case schedulingIndexing
99
- case indexing( preparationTasks: [ BuildTargetIdentifier : IndexTaskStatus ] , indexTasks: [ DocumentURI : IndexTaskStatus ] )
99
+ case indexing( preparationTasks: [ BuildTargetIdentifier : IndexTaskStatus ] , indexTasks: [ FileToIndex : IndexTaskStatus ] )
100
100
case upToDate
101
101
102
102
package func merging( with other: IndexProgressStatus ) -> IndexProgressStatus {
@@ -182,7 +182,7 @@ package final actor SemanticIndexManager {
182
182
/// store update task to be scheduled in the task scheduler or which currently have an index store update running.
183
183
///
184
184
/// After the file is indexed, it is removed from this dictionary.
185
- private var inProgressIndexTasks : [ DocumentURI : InProgressIndexStore ] = [ : ]
185
+ private var inProgressIndexTasks : [ FileToIndex : InProgressIndexStore ] = [ : ]
186
186
187
187
/// The currently running task that prepares a document for editor functionality.
188
188
///
@@ -431,11 +431,6 @@ package final actor SemanticIndexManager {
431
431
if !indexFilesWithUpToDateUnits, await indexStoreUpToDateTracker. isUpToDate ( $0) {
432
432
return false
433
433
}
434
- if case . waitingForPreparation = inProgressIndexTasks [ $0] {
435
- // We haven't started preparing the file yet. Scheduling a new index operation for it won't produce any
436
- // more recent results.
437
- return false
438
- }
439
434
return true
440
435
} . compactMap { ( uri) -> FileToIndex ? in
441
436
if sourceFiles. contains ( uri) {
@@ -462,6 +457,14 @@ package final actor SemanticIndexManager {
462
457
}
463
458
return . headerFile( header: uri, mainFile: mainFile)
464
459
}
460
+ . filter {
461
+ switch inProgressIndexTasks [ $0] {
462
+ case . waitingForPreparation:
463
+ return false
464
+ default :
465
+ return true
466
+ }
467
+ }
465
468
return filesToReIndex
466
469
}
467
470
@@ -626,14 +629,14 @@ package final actor SemanticIndexManager {
626
629
return
627
630
}
628
631
for fileAndTarget in filesAndTargets {
629
- switch self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
632
+ switch self . inProgressIndexTasks [ fileAndTarget. file] {
630
633
case . updatingIndexStore( let registeredTask, _) :
631
634
if registeredTask == OpaqueQueuedIndexTask ( task) {
632
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
635
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
633
636
}
634
637
case . waitingForPreparation( let registeredTask, _) , . preparing( let registeredTask, _) :
635
638
if registeredTask == preparationTaskID {
636
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
639
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
637
640
}
638
641
case nil :
639
642
break
@@ -642,9 +645,9 @@ package final actor SemanticIndexManager {
642
645
self . indexProgressStatusDidChange ( )
643
646
}
644
647
for fileAndTarget in filesAndTargets {
645
- switch inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
648
+ switch inProgressIndexTasks [ fileAndTarget. file] {
646
649
case . waitingForPreparation( preparationTaskID, let indexTask) , . preparing( preparationTaskID, let indexTask) :
647
- inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = . updatingIndexStore(
650
+ inProgressIndexTasks [ fileAndTarget. file] = . updatingIndexStore(
648
651
updateIndexStoreTask: OpaqueQueuedIndexTask ( updateIndexTask) ,
649
652
indexTask: indexTask
650
653
)
@@ -730,9 +733,9 @@ package final actor SemanticIndexManager {
730
733
if case . executing = newState {
731
734
for file in filesToIndex {
732
735
if case . waitingForPreparation( preparationTaskID: preparationTaskID, indexTask: let indexTask) =
733
- self . inProgressIndexTasks [ file. sourceFile ]
736
+ self . inProgressIndexTasks [ file]
734
737
{
735
- self . inProgressIndexTasks [ file. sourceFile ] = . preparing(
738
+ self . inProgressIndexTasks [ file] = . preparing(
736
739
preparationTaskID: preparationTaskID,
737
740
indexTask: indexTask
738
741
)
@@ -766,14 +769,14 @@ package final actor SemanticIndexManager {
766
769
// The number of index tasks that don't currently have an in-progress task associated with it.
767
770
// The denominator in the index progress should get incremented by this amount.
768
771
// We don't want to increment the denominator for tasks that already have an index in progress.
769
- let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0. sourceFile ] == nil } . count
772
+ let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0] == nil } . count
770
773
for file in filesToIndex {
771
774
// The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
772
775
// The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
773
776
// `.waitingForPreparation` here because we don't have an `await` call between the creation of `indexTask` and
774
777
// this loop, so we still have exclusive access to the `SemanticIndexManager` actor and hence `updateIndexStore`
775
778
// can't execute until we have set all index statuses to `.waitingForPreparation`.
776
- inProgressIndexTasks [ file. sourceFile ] = . waitingForPreparation(
779
+ inProgressIndexTasks [ file] = . waitingForPreparation(
777
780
preparationTaskID: preparationTaskID,
778
781
indexTask: indexTask
779
782
)
0 commit comments