From 4971acd1b72159554e51317f2dc2bab1cab011a2 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Mon, 22 Jul 2024 12:44:44 +0200 Subject: [PATCH] don't remove downstream diagnostics for best effort compilation --- .../scala/scala/meta/internal/metals/Compilations.scala | 4 ++-- .../main/scala/scala/meta/internal/metals/Diagnostics.scala | 6 +++++- .../tests/best-effort/BestEffortCompilationSuite.scala | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala index 3efe41fd795..189ffec6a5c 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Compilations.scala @@ -26,7 +26,7 @@ final class Compilations( workspace: () => AbsolutePath, languageClient: MetalsLanguageClient, refreshTestSuites: () => Unit, - afterSuccesfulCompilation: () => Unit, + afterSuccessfulCompilation: () => Unit, isCurrentlyFocused: b.BuildTargetIdentifier => Boolean, compileWorksheets: Seq[AbsolutePath] => Future[Unit], onStartCompilation: () => Unit, @@ -269,7 +269,7 @@ final class Compilations( val result = compilation.asScala .andThen { case result => updateCompiledTargetState(result) - afterSuccesfulCompilation() + afterSuccessfulCompilation() // See https://github.com/scalacenter/bloop/issues/1067 classes.rebuildIndex( diff --git a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala index 7feb5133bbc..efba5234f5f 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala @@ -95,7 +95,11 @@ final class Diagnostics( ): Unit = { val target = report.getTarget() - if (statusCode.isError) { + // if we use best effort compilation downstream targets + // should get recompiled even if compilation fails + def shouldUnpublishForDownstreamTargets = + !buildTargets.scalaTarget(target).exists(_.isBestEffort) + if (statusCode.isError && shouldUnpublishForDownstreamTargets) { removeInverseDependenciesDiagnostics(target) } else { buildTargetMapper.remove(target) diff --git a/tests/unit/src/test/scala/tests/best-effort/BestEffortCompilationSuite.scala b/tests/unit/src/test/scala/tests/best-effort/BestEffortCompilationSuite.scala index 941f4a968db..1b7df2cf55d 100644 --- a/tests/unit/src/test/scala/tests/best-effort/BestEffortCompilationSuite.scala +++ b/tests/unit/src/test/scala/tests/best-effort/BestEffortCompilationSuite.scala @@ -195,7 +195,7 @@ class BestEffortCompilationSuite } yield () } - // we check if previous sucessful best effort compilation artefacts remain + // we check if previous successful best effort compilation artifacts remain // after an unsuccessful best effort attempt. // Unsuccessful best effort attempts tend surface detailed exceptions // from bloop, so those will show up while this test is running.