Skip to content

Address review comments to #1216 #1274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions Sources/SemanticIndex/SemanticIndexManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,10 @@ public final actor SemanticIndexManager {
logger.info(
"Waiting for up-to-date index for \(uris.map { $0.fileURL?.lastPathComponent ?? $0.stringValue }.joined(separator: ", "))"
)
let filesWithOutOfDateIndex = uris.filter { uri in
switch indexStatus[uri] {
case .inProgress, nil: return true
case .upToDate: return false
}
}
// Create a new index task for the files that aren't up-to-date. The newly scheduled index tasks will
// - Wait for the existing index operations to finish if they have the same number of files.
// - Reschedule the background index task in favor of an index task with fewer source files.
await self.index(files: filesWithOutOfDateIndex, priority: nil).value
await self.index(files: uris, priority: nil).value
index.pollForUnitChangesAndWait()
logger.debug("Done waiting for up-to-date index")
}
Expand Down
13 changes: 6 additions & 7 deletions Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ public struct UpdateIndexStoreTaskDescription: TaskDescriptionProtocol {
buildSettings: FileBuildSettings,
toolchain: Toolchain
) async throws {
let indexingArguments = adjustSwiftCompilerArgumentsForIndexStoreUpdate(
buildSettings.compilerArguments,
fileToIndex: uri
)

guard let swiftc = toolchain.swiftc else {
logger.error(
"Not updating index store for \(uri.forLogging) because toolchain \(toolchain.identifier) does not contain a Swift compiler"
)
return
}

let indexingArguments = adjustSwiftCompilerArgumentsForIndexStoreUpdate(
buildSettings.compilerArguments,
fileToIndex: uri
)

let process = try Process.launch(
arguments: [swiftc.pathString] + indexingArguments,
workingDirectory: buildSettings.workingDirectory.map(AbsolutePath.init(validating:))
Expand Down Expand Up @@ -289,7 +289,6 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
result += [argument, nextArgument]
continue
}
result.append(argument)
}
result.append(argument)
}
Expand All @@ -299,7 +298,7 @@ private func adjustSwiftCompilerArgumentsForIndexStoreUpdate(
// batch mode is not compatible with -index-file
"-disable-batch-mode",
// Fake an output path so that we get a different unit file for every Swift file we background index
"-o", fileToIndex.pseudoPath + ".o",
"-index-unit-output-path", fileToIndex.pseudoPath + ".o",
Comment on lines -302 to +301
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this doesn't reallly matter. -index-unit-output-path only exists because we need it to be different to -o during a build. But for just background indexing, -o is fine.

]
return result
}