Skip to content

Commit 1553c9c

Browse files
committed
Don’t index files with fallback build settings
Fallback build settings don’t even have an indexstore path set, so we would never pick up any index data generated from them. Also, indexing with fallback args has some other problems: - If it did generate a unit file, we would consider the file’s index up-to-date even if the compiler arguments change, which basically means that we wouldn’t get any up-to-date-index even when we do get build settings for the file. - It’s unlikely that the index from a single file with fallback arguments will be very useful as it can’t tie into the rest of the project.
1 parent e4d8331 commit 1553c9c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ public struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
225225
logger.error("Not indexing \(file.forLogging) because it has no compiler arguments")
226226
return
227227
}
228+
if buildSettings.isFallback {
229+
// Fallback build settings don’t even have an indexstore path set, so they can't generate index data that we would
230+
// pick up. Also, indexing with fallback args has some other problems:
231+
// - If it did generate a unit file, we would consider the file’s index up-to-date even if the compiler arguments
232+
// change, which means that we wouldn't get any up-to-date-index even when we have build settings for the file.
233+
// - It's unlikely that the index from a single file with fallback arguments will be very useful as it can't tie
234+
// into the rest of the project.
235+
// So, don't index the file.
236+
logger.error("Not indexing \(file.forLogging) because it has fallback compiler arguments")
237+
return
238+
}
228239
guard let toolchain = await buildSystemManager.toolchain(for: file.mainFile, language) else {
229240
logger.error(
230241
"Not updating index store for \(file.forLogging) because no toolchain could be determined for the document"

0 commit comments

Comments
 (0)