@@ -96,7 +96,7 @@ package enum IndexTaskStatus: Comparable {
96
96
package enum IndexProgressStatus : Sendable , Equatable {
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
///
@@ -420,11 +420,6 @@ package final actor SemanticIndexManager {
420
420
if !indexFilesWithUpToDateUnits, await indexStoreUpToDateTracker. isUpToDate ( $0) {
421
421
return false
422
422
}
423
- if case . waitingForPreparation = inProgressIndexTasks [ $0] {
424
- // We haven't started preparing the file yet. Scheduling a new index operation for it won't produce any
425
- // more recent results.
426
- return false
427
- }
428
423
return true
429
424
} . compactMap { ( uri) -> FileToIndex ? in
430
425
if sourceFiles. contains ( uri) {
@@ -451,6 +446,14 @@ package final actor SemanticIndexManager {
451
446
}
452
447
return . headerFile( header: uri, mainFile: mainFile)
453
448
}
449
+ . filter {
450
+ switch inProgressIndexTasks [ $0] {
451
+ case . waitingForPreparation:
452
+ return false
453
+ default :
454
+ return true
455
+ }
456
+ }
454
457
return filesToReIndex
455
458
}
456
459
@@ -627,14 +630,14 @@ package final actor SemanticIndexManager {
627
630
return
628
631
}
629
632
for fileAndTarget in filesAndTargets {
630
- switch self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
633
+ switch self . inProgressIndexTasks [ fileAndTarget. file] {
631
634
case . updatingIndexStore( let registeredTask, _) :
632
635
if registeredTask == OpaqueQueuedIndexTask ( task) {
633
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
636
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
634
637
}
635
638
case . waitingForPreparation( let registeredTask, _) , . preparing( let registeredTask, _) :
636
639
if registeredTask == preparationTaskID {
637
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
640
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
638
641
}
639
642
case nil :
640
643
break
@@ -643,9 +646,9 @@ package final actor SemanticIndexManager {
643
646
self . indexProgressStatusDidChange ( )
644
647
}
645
648
for fileAndTarget in filesAndTargets {
646
- switch inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
649
+ switch inProgressIndexTasks [ fileAndTarget. file] {
647
650
case . waitingForPreparation( preparationTaskID, let indexTask) , . preparing( preparationTaskID, let indexTask) :
648
- inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = . updatingIndexStore(
651
+ inProgressIndexTasks [ fileAndTarget. file] = . updatingIndexStore(
649
652
updateIndexStoreTask: OpaqueQueuedIndexTask ( updateIndexTask) ,
650
653
indexTask: indexTask
651
654
)
@@ -731,9 +734,9 @@ package final actor SemanticIndexManager {
731
734
if case . executing = newState {
732
735
for file in filesToIndex {
733
736
if case . waitingForPreparation( preparationTaskID: preparationTaskID, indexTask: let indexTask) =
734
- self . inProgressIndexTasks [ file. sourceFile ]
737
+ self . inProgressIndexTasks [ file]
735
738
{
736
- self . inProgressIndexTasks [ file. sourceFile ] = . preparing(
739
+ self . inProgressIndexTasks [ file] = . preparing(
737
740
preparationTaskID: preparationTaskID,
738
741
indexTask: indexTask
739
742
)
@@ -767,14 +770,14 @@ package final actor SemanticIndexManager {
767
770
// The number of index tasks that don't currently have an in-progress task associated with it.
768
771
// The denominator in the index progress should get incremented by this amount.
769
772
// We don't want to increment the denominator for tasks that already have an index in progress.
770
- let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0. sourceFile ] == nil } . count
773
+ let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0] == nil } . count
771
774
for file in filesToIndex {
772
775
// The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
773
776
// The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
774
777
// `.waitingForPreparation` here because we don't have an `await` call between the creation of `indexTask` and
775
778
// this loop, so we still have exclusive access to the `SemanticIndexManager` actor and hence `updateIndexStore`
776
779
// can't execute until we have set all index statuses to `.waitingForPreparation`.
777
- inProgressIndexTasks [ file. sourceFile ] = . waitingForPreparation(
780
+ inProgressIndexTasks [ file] = . waitingForPreparation(
778
781
preparationTaskID: preparationTaskID,
779
782
indexTask: indexTask
780
783
)
0 commit comments