Skip to content

Commit 0f86e01

Browse files
authored
Merge pull request #1349 from ahoppen/address-review-comments-1322-1329
Address review comments from #1322 and #1329
2 parents 715796f + 9098e09 commit 0f86e01

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

Sources/SemanticIndex/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
add_library(SemanticIndex STATIC
33
CheckedIndex.swift
44
CompilerCommandLineOption.swift
5-
IndexStatusManager.swift
65
IndexTaskDescription.swift
76
PreparationTaskDescription.swift
87
SemanticIndexManager.swift
98
TestHooks.swift
109
UpdateIndexStoreTaskDescription.swift
10+
UpToDateTracker.swift
1111
)
1212
set_target_properties(SemanticIndex PROPERTIES
1313
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

Sources/SemanticIndex/PreparationTaskDescription.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct PreparationTaskDescription: IndexTaskDescription {
3535
/// The build system manager that is used to get the toolchain and build settings for the files to index.
3636
private let buildSystemManager: BuildSystemManager
3737

38-
private let preparationUpToDateStatus: IndexUpToDateStatusManager<ConfiguredTarget>
38+
private let preparationUpToDateTracker: UpToDateTracker<ConfiguredTarget>
3939

4040
/// See `SemanticIndexManager.indexProcessDidProduceResult`
4141
private let indexProcessDidProduceResult: @Sendable (IndexProcessResult) -> Void
@@ -59,13 +59,13 @@ public struct PreparationTaskDescription: IndexTaskDescription {
5959
init(
6060
targetsToPrepare: [ConfiguredTarget],
6161
buildSystemManager: BuildSystemManager,
62-
preparationUpToDateStatus: IndexUpToDateStatusManager<ConfiguredTarget>,
62+
preparationUpToDateTracker: UpToDateTracker<ConfiguredTarget>,
6363
indexProcessDidProduceResult: @escaping @Sendable (IndexProcessResult) -> Void,
6464
testHooks: IndexTestHooks
6565
) {
6666
self.targetsToPrepare = targetsToPrepare
6767
self.buildSystemManager = buildSystemManager
68-
self.preparationUpToDateStatus = preparationUpToDateStatus
68+
self.preparationUpToDateTracker = preparationUpToDateTracker
6969
self.indexProcessDidProduceResult = indexProcessDidProduceResult
7070
self.testHooks = testHooks
7171
}
@@ -76,7 +76,7 @@ public struct PreparationTaskDescription: IndexTaskDescription {
7676
// The last 2 digits should be sufficient to differentiate between multiple concurrently running preparation operations
7777
await withLoggingSubsystemAndScope(subsystem: indexLoggingSubsystem, scope: "preparation-\(id % 100)") {
7878
let targetsToPrepare = await targetsToPrepare.asyncFilter {
79-
await !preparationUpToDateStatus.isUpToDate($0)
79+
await !preparationUpToDateTracker.isUpToDate($0)
8080
}.sorted(by: {
8181
($0.targetID, $0.runDestinationID) < ($1.targetID, $1.runDestinationID)
8282
})
@@ -114,7 +114,7 @@ public struct PreparationTaskDescription: IndexTaskDescription {
114114
}
115115
await testHooks.preparationTaskDidFinish?(self)
116116
if !Task.isCancelled {
117-
await preparationUpToDateStatus.markUpToDate(targetsToPrepare, updateOperationStartDate: startDate)
117+
await preparationUpToDateTracker.markUpToDate(targetsToPrepare, updateOperationStartDate: startDate)
118118
}
119119
}
120120
}

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,9 @@ public final actor SemanticIndexManager {
111111
/// ...). `nil` if no build graph is currently being generated.
112112
private var generateBuildGraphTask: Task<Void, Never>?
113113

114-
private let preparationUpToDateStatus = IndexUpToDateStatusManager<ConfiguredTarget>()
114+
private let preparationUpToDateTracker = UpToDateTracker<ConfiguredTarget>()
115115

116-
private let indexStoreUpToDateStatus = IndexUpToDateStatusManager<DocumentURI>()
116+
private let indexStoreUpToDateTracker = UpToDateTracker<DocumentURI>()
117117

118118
/// The preparation tasks that have been started and are either scheduled in the task scheduler or currently
119119
/// executing.
@@ -305,23 +305,23 @@ public final actor SemanticIndexManager {
305305
// We only re-index the files that were changed and don't re-index any of their dependencies. See the
306306
// `Documentation/Files_To_Reindex.md` file.
307307
let changedFiles = events.map(\.uri)
308-
await indexStoreUpToDateStatus.markOutOfDate(changedFiles)
308+
await indexStoreUpToDateTracker.markOutOfDate(changedFiles)
309309

310310
// Note that configured targets are the right abstraction layer here (instead of a non-configured target) because a
311311
// build system might have targets that include different source files. Hence a source file might be in target T
312312
// configured for macOS but not in target T configured for iOS.
313313
let targets = await changedFiles.asyncMap { await buildSystemManager.configuredTargets(for: $0) }.flatMap { $0 }
314314
if let dependentTargets = await buildSystemManager.targets(dependingOn: targets) {
315-
await preparationUpToDateStatus.markOutOfDate(dependentTargets)
315+
await preparationUpToDateTracker.markOutOfDate(dependentTargets)
316316
} else {
317-
await preparationUpToDateStatus.markAllOutOfDate()
317+
await preparationUpToDateTracker.markAllKnownOutOfDate()
318318
// `markAllOutOfDate` only marks targets out-of-date that have been indexed before. Also mark all targets with
319319
// in-progress preparation out of date. So we don't get into the following situation, which would result in an
320320
// incorrect up-to-date status of a target
321321
// - Target preparation starts for the first time
322322
// - Files changed
323323
// - Target preparation finishes.
324-
await preparationUpToDateStatus.markOutOfDate(inProgressPreparationTasks.keys)
324+
await preparationUpToDateTracker.markOutOfDate(inProgressPreparationTasks.keys)
325325
}
326326

327327
await scheduleBackgroundIndex(files: changedFiles)
@@ -406,7 +406,7 @@ public final actor SemanticIndexManager {
406406
// schedule two preparations of the same target in quick succession, only the first one actually performs a prepare
407407
// and the second one will be a no-op once it runs.
408408
let targetsToPrepare = await targets.asyncFilter {
409-
await !preparationUpToDateStatus.isUpToDate($0)
409+
await !preparationUpToDateTracker.isUpToDate($0)
410410
}
411411

412412
guard !targetsToPrepare.isEmpty else {
@@ -417,7 +417,7 @@ public final actor SemanticIndexManager {
417417
PreparationTaskDescription(
418418
targetsToPrepare: targetsToPrepare,
419419
buildSystemManager: self.buildSystemManager,
420-
preparationUpToDateStatus: preparationUpToDateStatus,
420+
preparationUpToDateTracker: preparationUpToDateTracker,
421421
indexProcessDidProduceResult: indexProcessDidProduceResult,
422422
testHooks: testHooks
423423
)
@@ -464,7 +464,7 @@ public final actor SemanticIndexManager {
464464
filesToIndex: filesAndTargets,
465465
buildSystemManager: self.buildSystemManager,
466466
index: index,
467-
indexStoreUpToDateStatus: indexStoreUpToDateStatus,
467+
indexStoreUpToDateTracker: indexStoreUpToDateTracker,
468468
indexProcessDidProduceResult: indexProcessDidProduceResult,
469469
testHooks: testHooks
470470
)
@@ -509,7 +509,7 @@ public final actor SemanticIndexManager {
509509
// schedule two indexing jobs for the same file in quick succession, only the first one actually updates the index
510510
// store and the second one will be a no-op once it runs.
511511
let outOfDateFiles = await filesToIndex(toCover: files).asyncFilter {
512-
if await indexStoreUpToDateStatus.isUpToDate($0.sourceFile) {
512+
if await indexStoreUpToDateTracker.isUpToDate($0.sourceFile) {
513513
return false
514514
}
515515
guard let language = await buildSystemManager.defaultLanguage(for: $0.mainFile),

Sources/SemanticIndex/IndexStatusManager.swift renamed to Sources/SemanticIndex/UpToDateTracker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414
import SKCore
1515

1616
/// Keeps track of whether an item (a target or file to index) is up-to-date.
17-
actor IndexUpToDateStatusManager<Item: Hashable> {
17+
actor UpToDateTracker<Item: Hashable> {
1818
private enum Status {
1919
/// The item is up-to-date.
2020
case upToDate
@@ -57,7 +57,7 @@ actor IndexUpToDateStatusManager<Item: Hashable> {
5757
}
5858
}
5959

60-
func markAllOutOfDate() {
60+
func markAllKnownOutOfDate() {
6161
markOutOfDate(status.keys)
6262
}
6363

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
105105
/// The build system manager that is used to get the toolchain and build settings for the files to index.
106106
private let buildSystemManager: BuildSystemManager
107107

108-
private let indexStoreUpToDateStatus: IndexUpToDateStatusManager<DocumentURI>
108+
private let indexStoreUpToDateTracker: UpToDateTracker<DocumentURI>
109109

110110
/// A reference to the underlying index store. Used to check if the index is already up-to-date for a file, in which
111111
/// case we don't need to index it again.
@@ -138,14 +138,14 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
138138
filesToIndex: [FileAndTarget],
139139
buildSystemManager: BuildSystemManager,
140140
index: UncheckedIndex,
141-
indexStoreUpToDateStatus: IndexUpToDateStatusManager<DocumentURI>,
141+
indexStoreUpToDateTracker: UpToDateTracker<DocumentURI>,
142142
indexProcessDidProduceResult: @escaping @Sendable (IndexProcessResult) -> Void,
143143
testHooks: IndexTestHooks
144144
) {
145145
self.filesToIndex = filesToIndex
146146
self.buildSystemManager = buildSystemManager
147147
self.index = index
148-
self.indexStoreUpToDateStatus = indexStoreUpToDateStatus
148+
self.indexStoreUpToDateTracker = indexStoreUpToDateTracker
149149
self.indexProcessDidProduceResult = indexProcessDidProduceResult
150150
self.testHooks = testHooks
151151
}
@@ -202,7 +202,7 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
202202
}
203203

204204
private func updateIndexStore(forSingleFile file: FileToIndex, in target: ConfiguredTarget) async {
205-
guard await !indexStoreUpToDateStatus.isUpToDate(file.sourceFile) else {
205+
guard await !indexStoreUpToDateTracker.isUpToDate(file.sourceFile) else {
206206
// If we know that the file is up-to-date without having ot hit the index, do that because it's fastest.
207207
return
208208
}
@@ -264,7 +264,7 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
264264
"Not updating index store for \(file) because it is a language that is not supported by background indexing"
265265
)
266266
}
267-
await indexStoreUpToDateStatus.markUpToDate([file.sourceFile], updateOperationStartDate: startDate)
267+
await indexStoreUpToDateTracker.markUpToDate([file.sourceFile], updateOperationStartDate: startDate)
268268
}
269269

270270
private func updateIndexStore(

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ extension SourceKitLSPServer {
834834
nonisolated func indexTaskDidProduceResult(_ result: IndexProcessResult) {
835835
self.sendNotificationToClient(
836836
LogMessageNotification(
837-
type: result.failed ? .info : .warning,
837+
type: result.failed ? .warning : .info,
838838
message: """
839839
\(result.taskDescription) finished in \(result.duration)
840840
\(result.command)

Sources/sourcekit-lsp/SourceKitLSP.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ struct SourceKitLSP: AsyncParsableCommand {
208208

209209
@Flag(
210210
help: """
211-
Show which index tasks are currently running in the indexing work done progress. \
212-
This produces a multi-line work done progress, which might render incorrectly depending in the editor.
211+
When reporting index progress, show the currently running index tasks in addition to the task's count. \
212+
This produces a multi-line work done progress, which might render incorrectly, depending on the editor.
213213
"""
214214
)
215215
var experimentalShowActivePreparationTasksInProgress = false

0 commit comments

Comments
 (0)