@@ -452,11 +452,12 @@ object Compiler {
452452
453453 val backgroundTasks = new CompileBackgroundTasks {
454454 def trigger (
455- clientClassesDir : AbsolutePath ,
455+ clientClassesObserver : ClientClassesObserver ,
456456 clientReporter : Reporter ,
457457 clientTracer : BraveTracer ,
458458 clientLogger : Logger
459459 ): Task [Unit ] = Task .defer {
460+ val clientClassesDir = clientClassesObserver.classesDir
460461 clientLogger.debug(s " Triggering background tasks for $clientClassesDir" )
461462 val updateClientState =
462463 updateExternalClassesDirWithReadOnly(clientClassesDir, clientTracer, clientLogger)
@@ -472,10 +473,20 @@ object Compiler {
472473 }
473474
474475 val deleteNewClassesDir = Task (BloopPaths .delete(AbsolutePath (newClassesDir)))
475- val allTasks = List (deleteNewClassesDir, updateClientState, writeAnalysisIfMissing)
476+ val publishClientAnalysis = Task {
477+ rebaseAnalysisClassFiles(
478+ analysis,
479+ readOnlyClassesDir,
480+ clientClassesDir.underlying,
481+ sourcesWithFatal
482+ )
483+ }
484+ .flatMap(clientClassesObserver.nextAnalysis)
476485 Task
477- .gatherUnordered(allTasks)
478- .map(_ => ())
486+ .gatherUnordered(
487+ List (deleteNewClassesDir, updateClientState, writeAnalysisIfMissing)
488+ )
489+ .flatMap(_ => publishClientAnalysis)
479490 .onErrorHandleWith(err => {
480491 clientLogger.debug(" Caught error in background tasks" ); clientLogger.trace(err);
481492 Task .raiseError(err)
@@ -495,14 +506,12 @@ object Compiler {
495506 )
496507 } else {
497508 val allGeneratedProducts = allGeneratedRelativeClassFilePaths.toMap
498- val analysisForFutureCompilationRuns = {
499- rebaseAnalysisClassFiles(
500- analysis,
501- readOnlyClassesDir,
502- newClassesDir,
503- sourcesWithFatal
504- )
505- }
509+ val analysisForFutureCompilationRuns = rebaseAnalysisClassFiles(
510+ analysis,
511+ readOnlyClassesDir,
512+ newClassesDir,
513+ sourcesWithFatal
514+ )
506515
507516 val resultForFutureCompilationRuns = {
508517 resultForDependentCompilationsInSameRun.withAnalysis(
@@ -517,12 +526,12 @@ object Compiler {
517526 // Schedule the tasks to run concurrently after the compilation end
518527 val backgroundTasksExecution = new CompileBackgroundTasks {
519528 def trigger (
520- clientClassesDir : AbsolutePath ,
529+ clientClassesObserver : ClientClassesObserver ,
521530 clientReporter : Reporter ,
522531 clientTracer : BraveTracer ,
523532 clientLogger : Logger
524533 ): Task [Unit ] = {
525- val clientClassesDirPath = clientClassesDir.toString
534+ val clientClassesDir = clientClassesObserver.classesDir
526535 val successBackgroundTasks =
527536 backgroundTasksWhenNewSuccessfulAnalysis
528537 .map(f => f(clientClassesDir, clientReporter, clientTracer))
@@ -543,15 +552,26 @@ object Compiler {
543552 val syntax = path.syntax
544553 if (syntax.startsWith(readOnlyClassesDirPath)) {
545554 val rebasedFile = AbsolutePath (
546- syntax.replace(readOnlyClassesDirPath, clientClassesDirPath )
555+ syntax.replace(readOnlyClassesDirPath, clientClassesDir.toString )
547556 )
548557 if (rebasedFile.exists) {
549558 Files .delete(rebasedFile.underlying)
550559 }
551560 }
552561 }
553562 }
554- Task .gatherUnordered(List (firstTask, secondTask)).map(_ => ())
563+
564+ val publishClientAnalysis = Task {
565+ rebaseAnalysisClassFiles(
566+ analysis,
567+ newClassesDir,
568+ clientClassesDir.underlying,
569+ sourcesWithFatal
570+ )
571+ }.flatMap(clientClassesObserver.nextAnalysis)
572+ Task
573+ .gatherUnordered(List (firstTask, secondTask))
574+ .flatMap(_ => publishClientAnalysis)
555575 }
556576
557577 allClientSyncTasks.doOnFinish(_ => Task (clientReporter.reportEndCompilation()))
@@ -691,11 +711,12 @@ object Compiler {
691711 ): CompileBackgroundTasks = {
692712 new CompileBackgroundTasks {
693713 def trigger (
694- clientClassesDir : AbsolutePath ,
714+ clientClassesObserver : ClientClassesObserver ,
695715 clientReporter : Reporter ,
696716 tracer : BraveTracer ,
697717 clientLogger : Logger
698718 ): Task [Unit ] = {
719+ val clientClassesDir = clientClassesObserver.classesDir
699720 val backgroundTasks = tasks.map(f => f(clientClassesDir, clientReporter, tracer))
700721 Task .gatherUnordered(backgroundTasks).memoize.map(_ => ())
701722 }
@@ -783,19 +804,19 @@ object Compiler {
783804 */
784805 def rebaseAnalysisClassFiles (
785806 analysis0 : CompileAnalysis ,
786- readOnlyClassesDir : Path ,
787- newClassesDir : Path ,
807+ origin : Path ,
808+ target : Path ,
788809 sourceFilesWithFatalWarnings : scala.collection.Set [File ]
789810 ): Analysis = {
790811 // Cast to the only internal analysis that we support
791812 val analysis = analysis0.asInstanceOf [Analysis ]
792813 def rebase (file : VirtualFileRef ): VirtualFileRef = {
793814
794815 val filePath = converter.toPath(file).toAbsolutePath()
795- if (! filePath.startsWith(readOnlyClassesDir )) file
816+ if (! filePath.startsWith(origin )) file
796817 else {
797818 // Hash for class file is the same because the copy duplicates metadata
798- val path = newClassesDir .resolve(readOnlyClassesDir .relativize(filePath))
819+ val path = target .resolve(origin .relativize(filePath))
799820 converter.toVirtualFile(path)
800821 }
801822 }
0 commit comments