Skip to content

Commit d4a42ea

Browse files
authored
Merge pull request #1274 from ahoppen/indexing-review-comments
2 parents 6a791fd + 7b4bbeb commit d4a42ea

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,10 @@ public final actor SemanticIndexManager {
9797
logger.info(
9898
"Waiting for up-to-date index for \(uris.map { $0.fileURL?.lastPathComponent ?? $0.stringValue }.joined(separator: ", "))"
9999
)
100-
let filesWithOutOfDateIndex = uris.filter { uri in
101-
switch indexStatus[uri] {
102-
case .inProgress, nil: return true
103-
case .upToDate: return false
104-
}
105-
}
106100
// Create a new index task for the files that aren't up-to-date. The newly scheduled index tasks will
107101
// - Wait for the existing index operations to finish if they have the same number of files.
108102
// - Reschedule the background index task in favor of an index task with fewer source files.
109-
await self.index(files: filesWithOutOfDateIndex, priority: nil).value
103+
await self.index(files: uris, priority: nil).value
110104
index.pollForUnitChangesAndWait()
111105
logger.debug("Done waiting for up-to-date index")
112106
}

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,18 @@ public struct UpdateIndexStoreTaskDescription: TaskDescriptionProtocol {
176176
buildSettings: FileBuildSettings,
177177
toolchain: Toolchain
178178
) async throws {
179-
let indexingArguments = adjustSwiftCompilerArgumentsForIndexStoreUpdate(
180-
buildSettings.compilerArguments,
181-
fileToIndex: uri
182-
)
183-
184179
guard let swiftc = toolchain.swiftc else {
185180
logger.error(
186181
"Not updating index store for \(uri.forLogging) because toolchain \(toolchain.identifier) does not contain a Swift compiler"
187182
)
188183
return
189184
}
190185

186+
let indexingArguments = adjustSwiftCompilerArgumentsForIndexStoreUpdate(
187+
buildSettings.compilerArguments,
188+
fileToIndex: uri
189+
)
190+
191191
let process = try Process.launch(
192192
arguments: [swiftc.pathString] + indexingArguments,
193193
workingDirectory: buildSettings.workingDirectory.map(AbsolutePath.init(validating:))
@@ -289,7 +289,6 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
289289
result += [argument, nextArgument]
290290
continue
291291
}
292-
result.append(argument)
293292
}
294293
result.append(argument)
295294
}
@@ -299,7 +298,7 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
299298
// batch mode is not compatible with -index-file
300299
"-disable-batch-mode",
301300
// Fake an output path so that we get a different unit file for every Swift file we background index
302-
"-o", fileToIndex.pseudoPath + ".o",
301+
"-index-unit-output-path", fileToIndex.pseudoPath + ".o",
303302
]
304303
return result
305304
}

0 commit comments

Comments
 (0)