@@ -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
@@ -638,14 +641,14 @@ package final actor SemanticIndexManager {
638
641
return
639
642
}
640
643
for fileAndTarget in filesAndTargets {
641
- switch self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
644
+ switch self . inProgressIndexTasks [ fileAndTarget. file] {
642
645
case . updatingIndexStore( let registeredTask, _) :
643
646
if registeredTask == OpaqueQueuedIndexTask ( task) {
644
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
647
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
645
648
}
646
649
case . waitingForPreparation( let registeredTask, _) , . preparing( let registeredTask, _) :
647
650
if registeredTask == preparationTaskID {
648
- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
651
+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
649
652
}
650
653
case nil :
651
654
break
@@ -654,9 +657,9 @@ package final actor SemanticIndexManager {
654
657
self . indexProgressStatusDidChange ( )
655
658
}
656
659
for fileAndTarget in filesAndTargets {
657
- switch inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
660
+ switch inProgressIndexTasks [ fileAndTarget. file] {
658
661
case . waitingForPreparation( preparationTaskID, let indexTask) , . preparing( preparationTaskID, let indexTask) :
659
- inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = . updatingIndexStore(
662
+ inProgressIndexTasks [ fileAndTarget. file] = . updatingIndexStore(
660
663
updateIndexStoreTask: OpaqueQueuedIndexTask ( updateIndexTask) ,
661
664
indexTask: indexTask
662
665
)
@@ -742,9 +745,9 @@ package final actor SemanticIndexManager {
742
745
if case . executing = newState {
743
746
for file in filesToIndex {
744
747
if case . waitingForPreparation( preparationTaskID: preparationTaskID, indexTask: let indexTask) =
745
- self . inProgressIndexTasks [ file. sourceFile ]
748
+ self . inProgressIndexTasks [ file]
746
749
{
747
- self . inProgressIndexTasks [ file. sourceFile ] = . preparing(
750
+ self . inProgressIndexTasks [ file] = . preparing(
748
751
preparationTaskID: preparationTaskID,
749
752
indexTask: indexTask
750
753
)
@@ -778,14 +781,14 @@ package final actor SemanticIndexManager {
778
781
// The number of index tasks that don't currently have an in-progress task associated with it.
779
782
// The denominator in the index progress should get incremented by this amount.
780
783
// We don't want to increment the denominator for tasks that already have an index in progress.
781
- let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0. sourceFile ] == nil } . count
784
+ let newIndexTasks = filesToIndex. filter { inProgressIndexTasks [ $0] == nil } . count
782
785
for file in filesToIndex {
783
786
// The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
784
787
// The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
785
788
// `.waitingForPreparation` here because we don't have an `await` call between the creation of `indexTask` and
786
789
// this loop, so we still have exclusive access to the `SemanticIndexManager` actor and hence `updateIndexStore`
787
790
// can't execute until we have set all index statuses to `.waitingForPreparation`.
788
- inProgressIndexTasks [ file. sourceFile ] = . waitingForPreparation(
791
+ inProgressIndexTasks [ file] = . waitingForPreparation(
789
792
preparationTaskID: preparationTaskID,
790
793
indexTask: indexTask
791
794
)
0 commit comments