@@ -298,7 +298,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
298
298
case . swift:
299
299
do {
300
300
try await updateIndexStore (
301
- forSwiftFile : fileInfo. mainFile,
301
+ forSwiftFiles : [ fileInfo. mainFile] ,
302
302
buildSettings: buildSettings,
303
303
toolchain: toolchain
304
304
)
@@ -329,7 +329,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
329
329
/// If `args` does not contain an `-index-store-path` argument, add it, pointing to the build server's index store
330
330
/// path. If an `-index-store-path` already exists, validate that it matches the build server's index store path and
331
331
/// replace it by the build server's index store path if they don't match.
332
- private func addOrReplaceIndexStorePath( in args: [ String ] , for uri : DocumentURI ) async throws -> [ String ] {
332
+ private func addOrReplaceIndexStorePath( in args: [ String ] , for uris : [ DocumentURI ] ) async throws -> [ String ] {
333
333
var args = args
334
334
guard let buildServerIndexStorePath = await self . buildServerManager. initializationData? . indexStorePath else {
335
335
struct NoIndexStorePathError : Error { }
@@ -340,9 +340,9 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
340
340
if indexStorePath != buildServerIndexStorePath {
341
341
logger. error (
342
342
"""
343
- Compiler arguments for \( uri ) specify index store path \( indexStorePath) but build server specified an \
343
+ Compiler arguments for specify index store path \( indexStorePath) but build server specified an \
344
344
incompatible index store path \( buildServerIndexStorePath) . Overriding with the path specified by the build \
345
- system.
345
+ system. For \( uris )
346
346
"""
347
347
)
348
348
args [ indexStorePathIndex + 1 ] = buildServerIndexStorePath
@@ -354,28 +354,27 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
354
354
}
355
355
356
356
private func updateIndexStore(
357
- forSwiftFile uri : DocumentURI ,
357
+ forSwiftFiles uris : [ DocumentURI ] ,
358
358
buildSettings: FileBuildSettings ,
359
359
toolchain: Toolchain
360
360
) async throws {
361
361
guard let swiftc = toolchain. swiftc else {
362
362
logger. error (
363
- " Not updating index store for \( uri . forLogging ) because toolchain \( toolchain. identifier) does not contain a Swift compiler "
363
+ " Not updating index store for \( uris ) because toolchain \( toolchain. identifier) does not contain a Swift compiler "
364
364
)
365
365
return
366
366
}
367
367
368
368
var args =
369
369
try [ swiftc. filePath] + buildSettings. compilerArguments + [
370
370
" -index-file " ,
371
- " -index-file-path " , uri. pseudoPath,
372
371
// batch mode is not compatible with -index-file
373
372
" -disable-batch-mode " ,
374
- ]
375
- args = try await addOrReplaceIndexStorePath ( in: args, for: uri )
373
+ ] + uris . flatMap { [ " -index-file-path " , $0 . pseudoPath ] }
374
+ args = try await addOrReplaceIndexStorePath ( in: args, for: uris )
376
375
377
376
try await runIndexingProcess (
378
- indexFile : uri ,
377
+ indexFiles : uris ,
379
378
buildSettings: buildSettings,
380
379
processArguments: args,
381
380
workingDirectory: buildSettings. workingDirectory. map ( AbsolutePath . init ( validating: ) )
@@ -395,18 +394,18 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
395
394
}
396
395
397
396
var args = [ try clang. filePath] + buildSettings. compilerArguments
398
- args = try await addOrReplaceIndexStorePath ( in: args, for: uri)
397
+ args = try await addOrReplaceIndexStorePath ( in: args, for: [ uri] )
399
398
400
399
try await runIndexingProcess (
401
- indexFile : uri,
400
+ indexFiles : [ uri] ,
402
401
buildSettings: buildSettings,
403
402
processArguments: args,
404
403
workingDirectory: buildSettings. workingDirectory. map ( AbsolutePath . init ( validating: ) )
405
404
)
406
405
}
407
406
408
407
private func runIndexingProcess(
409
- indexFile : DocumentURI ,
408
+ indexFiles : [ DocumentURI ] ,
410
409
buildSettings: FileBuildSettings ,
411
410
processArguments: [ String ] ,
412
411
workingDirectory: AbsolutePath ?
@@ -420,7 +419,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
420
419
let state = signposter. beginInterval (
421
420
" Indexing " ,
422
421
id: signpostID,
423
- " Indexing \( indexFile . fileURL? . lastPathComponent ?? indexFile . pseudoPath) "
422
+ " Indexing \( indexFiles . map { $0 . fileURL? . lastPathComponent ?? $0 . pseudoPath } ) "
424
423
)
425
424
defer {
426
425
signposter. endInterval ( " Indexing " , state)
@@ -429,7 +428,9 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
429
428
logMessageToIndexLog (
430
429
processArguments. joined ( separator: " " ) ,
431
430
. info,
432
- . begin( StructuredLogBegin ( title: " Indexing \( indexFile. pseudoPath) " , taskID: taskId) )
431
+ . begin(
432
+ StructuredLogBegin ( title: " Indexing \( indexFiles. map ( \. pseudoPath) . joined ( separator: " , " ) ) " , taskID: taskId)
433
+ )
433
434
)
434
435
435
436
let stdoutHandler = PipeAsStringHandler {
@@ -475,26 +476,26 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
475
476
// Indexing will frequently fail if the source code is in an invalid state. Thus, log the failure at a low level.
476
477
logger. debug (
477
478
"""
478
- Updating index store for \( indexFile . forLogging ) terminated with non-zero exit code \( code)
479
+ Updating index store for terminated with non-zero exit code \( code) for \( indexFiles )
479
480
Stderr:
480
481
\( stderr)
481
482
Stdout:
482
483
\( stdout)
483
484
"""
484
485
)
485
- BuildSettingsLogger . log ( level: . debug, settings: buildSettings, for: indexFile)
486
+ // BuildSettingsLogger.log(level: .debug, settings: buildSettings, for: indexFile)
486
487
case . signalled( let signal) :
487
488
if !Task. isCancelled {
488
489
// The indexing job finished with a signal. Could be because the compiler crashed.
489
490
// Ignore signal exit codes if this task has been cancelled because the compiler exits with SIGINT if it gets
490
491
// interrupted.
491
- logger. error ( " Updating index store for \( indexFile . forLogging ) signaled \( signal ) " )
492
- BuildSettingsLogger . log ( level: . error, settings: buildSettings, for: indexFile)
492
+ logger. error ( " Updating index store for signaled \( signal ) for \( indexFiles ) " )
493
+ // BuildSettingsLogger.log(level: .error, settings: buildSettings, for: indexFile)
493
494
}
494
495
case . abnormal( let exception) :
495
496
if !Task. isCancelled {
496
- logger. error ( " Updating index store for \( indexFile . forLogging ) exited abnormally \( exception ) " )
497
- BuildSettingsLogger . log ( level: . error, settings: buildSettings, for: indexFile)
497
+ logger. error ( " Updating index store exited abnormally \( exception ) for \( indexFiles ) " )
498
+ // BuildSettingsLogger.log(level: .error, settings: buildSettings, for: indexFile)
498
499
}
499
500
}
500
501
}
0 commit comments