@@ -96,7 +96,7 @@ package enum IndexTaskStatus: Comparable {
9696package enum IndexProgressStatus : Sendable , Equatable {
9797 case preparingFileForEditorFunctionality
9898 case schedulingIndexing
99- case indexing( preparationTasks: [ BuildTargetIdentifier : IndexTaskStatus ] , indexTasks: [ DocumentURI : IndexTaskStatus ] )
99+ case indexing( preparationTasks: [ BuildTargetIdentifier : IndexTaskStatus ] , indexTasks: [ FileToIndex : IndexTaskStatus ] )
100100 case upToDate
101101
102102 package func merging( with other: IndexProgressStatus ) -> IndexProgressStatus {
@@ -182,7 +182,7 @@ package final actor SemanticIndexManager {
182182 /// store update task to be scheduled in the task scheduler or which currently have an index store update running.
183183 ///
184184 /// After the file is indexed, it is removed from this dictionary.
185- private var inProgressIndexTasks : [ DocumentURI : InProgressIndexStore ] = [ : ]
185+ private var inProgressIndexTasks : [ FileToIndex : InProgressIndexStore ] = [ : ]
186186
187187 /// The currently running task that prepares a document for editor functionality.
188188 ///
@@ -420,11 +420,6 @@ package final actor SemanticIndexManager {
420420 if !indexFilesWithUpToDateUnits, await indexStoreUpToDateTracker. isUpToDate ( $0) {
421421 return false
422422 }
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- }
428423 return true
429424 } . compactMap { ( uri) -> FileToIndex ? in
430425 if sourceFiles. contains ( uri) {
@@ -451,6 +446,14 @@ package final actor SemanticIndexManager {
451446 }
452447 return . headerFile( header: uri, mainFile: mainFile)
453448 }
449+ . filter {
450+ switch inProgressIndexTasks [ $0] {
451+ case . waitingForPreparation:
452+ return false
453+ default :
454+ return true
455+ }
456+ }
454457 return filesToReIndex
455458 }
456459
@@ -627,14 +630,14 @@ package final actor SemanticIndexManager {
627630 return
628631 }
629632 for fileAndTarget in filesAndTargets {
630- switch self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
633+ switch self . inProgressIndexTasks [ fileAndTarget. file] {
631634 case . updatingIndexStore( let registeredTask, _) :
632635 if registeredTask == OpaqueQueuedIndexTask ( task) {
633- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
636+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
634637 }
635638 case . waitingForPreparation( let registeredTask, _) , . preparing( let registeredTask, _) :
636639 if registeredTask == preparationTaskID {
637- self . inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = nil
640+ self . inProgressIndexTasks [ fileAndTarget. file] = nil
638641 }
639642 case nil :
640643 break
@@ -643,9 +646,9 @@ package final actor SemanticIndexManager {
643646 self . indexProgressStatusDidChange ( )
644647 }
645648 for fileAndTarget in filesAndTargets {
646- switch inProgressIndexTasks [ fileAndTarget. file. sourceFile ] {
649+ switch inProgressIndexTasks [ fileAndTarget. file] {
647650 case . waitingForPreparation( preparationTaskID, let indexTask) , . preparing( preparationTaskID, let indexTask) :
648- inProgressIndexTasks [ fileAndTarget. file. sourceFile ] = . updatingIndexStore(
651+ inProgressIndexTasks [ fileAndTarget. file] = . updatingIndexStore(
649652 updateIndexStoreTask: OpaqueQueuedIndexTask ( updateIndexTask) ,
650653 indexTask: indexTask
651654 )
@@ -731,9 +734,9 @@ package final actor SemanticIndexManager {
731734 if case . executing = newState {
732735 for file in filesToIndex {
733736 if case . waitingForPreparation( preparationTaskID: preparationTaskID, indexTask: let indexTask) =
734- self . inProgressIndexTasks [ file. sourceFile ]
737+ self . inProgressIndexTasks [ file]
735738 {
736- self . inProgressIndexTasks [ file. sourceFile ] = . preparing(
739+ self . inProgressIndexTasks [ file] = . preparing(
737740 preparationTaskID: preparationTaskID,
738741 indexTask: indexTask
739742 )
@@ -767,14 +770,14 @@ package final actor SemanticIndexManager {
767770 // The number of index tasks that don't currently have an in-progress task associated with it.
768771 // The denominator in the index progress should get incremented by this amount.
769772 // 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
771774 for file in filesToIndex {
772775 // The state of `inProgressIndexTasks` will get pushed on from `updateIndexStore`.
773776 // The updates to `inProgressIndexTasks` from `updateIndexStore` cannot race with setting it to
774777 // `.waitingForPreparation` here because we don't have an `await` call between the creation of `indexTask` and
775778 // this loop, so we still have exclusive access to the `SemanticIndexManager` actor and hence `updateIndexStore`
776779 // can't execute until we have set all index statuses to `.waitingForPreparation`.
777- inProgressIndexTasks [ file. sourceFile ] = . waitingForPreparation(
780+ inProgressIndexTasks [ file] = . waitingForPreparation(
778781 preparationTaskID: preparationTaskID,
779782 indexTask: indexTask
780783 )
0 commit comments