@@ -298,7 +298,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
298298 case . swift:
299299 do {
300300 try await updateIndexStore (
301- forSwiftFile : fileInfo. mainFile,
301+ forSwiftFiles : [ fileInfo. mainFile] ,
302302 buildSettings: buildSettings,
303303 toolchain: toolchain
304304 )
@@ -329,7 +329,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
329329 /// If `args` does not contain an `-index-store-path` argument, add it, pointing to the build server's index store
330330 /// path. If an `-index-store-path` already exists, validate that it matches the build server's index store path and
331331 /// 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 ] {
333333 var args = args
334334 guard let buildServerIndexStorePath = await self . buildServerManager. initializationData? . indexStorePath else {
335335 struct NoIndexStorePathError : Error { }
@@ -340,9 +340,9 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
340340 if indexStorePath != buildServerIndexStorePath {
341341 logger. error (
342342 """
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 \
344344 incompatible index store path \( buildServerIndexStorePath) . Overriding with the path specified by the build \
345- system.
345+ system. For \( uris )
346346 """
347347 )
348348 args [ indexStorePathIndex + 1 ] = buildServerIndexStorePath
@@ -354,28 +354,27 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
354354 }
355355
356356 private func updateIndexStore(
357- forSwiftFile uri : DocumentURI ,
357+ forSwiftFiles uris : [ DocumentURI ] ,
358358 buildSettings: FileBuildSettings ,
359359 toolchain: Toolchain
360360 ) async throws {
361361 guard let swiftc = toolchain. swiftc else {
362362 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 "
364364 )
365365 return
366366 }
367367
368368 var args =
369369 try [ swiftc. filePath] + buildSettings. compilerArguments + [
370370 " -index-file " ,
371- " -index-file-path " , uri. pseudoPath,
372371 // batch mode is not compatible with -index-file
373372 " -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 )
376375
377376 try await runIndexingProcess (
378- indexFile : uri ,
377+ indexFiles : uris ,
379378 buildSettings: buildSettings,
380379 processArguments: args,
381380 workingDirectory: buildSettings. workingDirectory. map ( AbsolutePath . init ( validating: ) )
@@ -395,18 +394,18 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
395394 }
396395
397396 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] )
399398
400399 try await runIndexingProcess (
401- indexFile : uri,
400+ indexFiles : [ uri] ,
402401 buildSettings: buildSettings,
403402 processArguments: args,
404403 workingDirectory: buildSettings. workingDirectory. map ( AbsolutePath . init ( validating: ) )
405404 )
406405 }
407406
408407 private func runIndexingProcess(
409- indexFile : DocumentURI ,
408+ indexFiles : [ DocumentURI ] ,
410409 buildSettings: FileBuildSettings ,
411410 processArguments: [ String ] ,
412411 workingDirectory: AbsolutePath ?
@@ -420,7 +419,7 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
420419 let state = signposter. beginInterval (
421420 " Indexing " ,
422421 id: signpostID,
423- " Indexing \( indexFile . fileURL? . lastPathComponent ?? indexFile . pseudoPath) "
422+ " Indexing \( indexFiles . map { $0 . fileURL? . lastPathComponent ?? $0 . pseudoPath } ) "
424423 )
425424 defer {
426425 signposter. endInterval ( " Indexing " , state)
@@ -429,7 +428,9 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
429428 logMessageToIndexLog (
430429 processArguments. joined ( separator: " " ) ,
431430 . info,
432- . begin( StructuredLogBegin ( title: " Indexing \( indexFile. pseudoPath) " , taskID: taskId) )
431+ . begin(
432+ StructuredLogBegin ( title: " Indexing \( indexFiles. map ( \. pseudoPath) . joined ( separator: " , " ) ) " , taskID: taskId)
433+ )
433434 )
434435
435436 let stdoutHandler = PipeAsStringHandler {
@@ -475,26 +476,26 @@ package struct UpdateIndexStoreTaskDescription: IndexTaskDescription {
475476 // Indexing will frequently fail if the source code is in an invalid state. Thus, log the failure at a low level.
476477 logger. debug (
477478 """
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 )
479480 Stderr:
480481 \( stderr)
481482 Stdout:
482483 \( stdout)
483484 """
484485 )
485- BuildSettingsLogger . log ( level: . debug, settings: buildSettings, for: indexFile)
486+ // BuildSettingsLogger.log(level: .debug, settings: buildSettings, for: indexFile)
486487 case . signalled( let signal) :
487488 if !Task. isCancelled {
488489 // The indexing job finished with a signal. Could be because the compiler crashed.
489490 // Ignore signal exit codes if this task has been cancelled because the compiler exits with SIGINT if it gets
490491 // 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)
493494 }
494495 case . abnormal( let exception) :
495496 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)
498499 }
499500 }
500501 }
0 commit comments