mirror of https://github.com/sbt/sbt.git
parent
80e87531d3
commit
f118d2d73b
|
|
@ -2329,7 +2329,7 @@ object Defaults extends BuildCommon {
|
||||||
val result0 = incCompiler
|
val result0 = incCompiler
|
||||||
.asInstanceOf[sbt.internal.inc.IncrementalCompilerImpl]
|
.asInstanceOf[sbt.internal.inc.IncrementalCompilerImpl]
|
||||||
.compileAllJava(in, s.log)
|
.compileAllJava(in, s.log)
|
||||||
reporter.sendSuccessReport(result0.analysis())
|
reporter.sendSuccessReport(result0.analysis(), Analysis.empty, false)
|
||||||
result0.withHasModified(result0.hasModified || r.hasModified)
|
result0.withHasModified(result0.hasModified || r.hasModified)
|
||||||
} else r
|
} else r
|
||||||
} catch {
|
} catch {
|
||||||
|
|
@ -2366,7 +2366,11 @@ object Defaults extends BuildCommon {
|
||||||
.withSetup(onProgress(setup))
|
.withSetup(onProgress(setup))
|
||||||
try {
|
try {
|
||||||
val result = incCompiler.compile(i, s.log)
|
val result = incCompiler.compile(i, s.log)
|
||||||
reporter.sendSuccessReport(result.getAnalysis, prev)
|
reporter.sendSuccessReport(
|
||||||
|
result.getAnalysis,
|
||||||
|
prev,
|
||||||
|
BuildServerProtocol.shouldReportAllPreviousProblems(task.targetId)
|
||||||
|
)
|
||||||
result
|
result
|
||||||
} catch {
|
} catch {
|
||||||
case e: Throwable =>
|
case e: Throwable =>
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,26 @@ import scala.collection.mutable
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import scala.util.{ Failure, Success, Try }
|
import scala.util.{ Failure, Success, Try }
|
||||||
import scala.annotation.nowarn
|
import scala.annotation.nowarn
|
||||||
|
import scala.collection.concurrent.TrieMap
|
||||||
import sbt.testing.Framework
|
import sbt.testing.Framework
|
||||||
|
|
||||||
object BuildServerProtocol {
|
object BuildServerProtocol {
|
||||||
import sbt.internal.bsp.codec.JsonProtocol._
|
import sbt.internal.bsp.codec.JsonProtocol._
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keep track of those projects that were compiled at least once so that we can
|
||||||
|
* decide to enable fresh reporting for projects that are compiled for the first time.
|
||||||
|
*
|
||||||
|
* see: https://github.com/scalacenter/bloop/issues/726
|
||||||
|
*/
|
||||||
|
private val compiledTargetsAtLeastOnce = new TrieMap[bsp.BuildTargetIdentifier, Boolean]()
|
||||||
|
def shouldReportAllPreviousProblems(id: bsp.BuildTargetIdentifier): Boolean = {
|
||||||
|
compiledTargetsAtLeastOnce.putIfAbsent(id, true) match {
|
||||||
|
case Some(_) => false
|
||||||
|
case None => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val capabilities = BuildServerCapabilities(
|
private val capabilities = BuildServerCapabilities(
|
||||||
CompileProvider(BuildServerConnection.languages),
|
CompileProvider(BuildServerConnection.languages),
|
||||||
TestProvider(BuildServerConnection.languages),
|
TestProvider(BuildServerConnection.languages),
|
||||||
|
|
@ -354,6 +369,7 @@ object BuildServerProtocol {
|
||||||
case r if r.method == Method.Initialize =>
|
case r if r.method == Method.Initialize =>
|
||||||
val params = Converter.fromJson[InitializeBuildParams](json(r)).get
|
val params = Converter.fromJson[InitializeBuildParams](json(r)).get
|
||||||
checkMetalsCompatibility(semanticdbEnabled, semanticdbVersion, params, callback.log)
|
checkMetalsCompatibility(semanticdbEnabled, semanticdbVersion, params, callback.log)
|
||||||
|
compiledTargetsAtLeastOnce.clear()
|
||||||
|
|
||||||
val response = InitializeBuildResult(
|
val response = InitializeBuildResult(
|
||||||
"sbt",
|
"sbt",
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,11 @@ sealed trait BuildServerReporter extends Reporter {
|
||||||
|
|
||||||
protected def publishDiagnostic(problem: Problem): Unit
|
protected def publishDiagnostic(problem: Problem): Unit
|
||||||
|
|
||||||
def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit
|
def sendSuccessReport(
|
||||||
|
analysis: CompileAnalysis,
|
||||||
|
prev: CompileAnalysis,
|
||||||
|
reportAllPreviousProblems: Boolean
|
||||||
|
): Unit
|
||||||
|
|
||||||
def sendFailureReport(sources: Array[VirtualFile]): Unit
|
def sendFailureReport(sources: Array[VirtualFile]): Unit
|
||||||
|
|
||||||
|
|
@ -86,7 +90,11 @@ final class BuildServerReporterImpl(
|
||||||
if (ref.id().contains("<")) None
|
if (ref.id().contains("<")) None
|
||||||
else Some(converter.toPath(ref))
|
else Some(converter.toPath(ref))
|
||||||
|
|
||||||
override def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit = {
|
override def sendSuccessReport(
|
||||||
|
analysis: CompileAnalysis,
|
||||||
|
prev: CompileAnalysis,
|
||||||
|
reportAllPreviousProblems: Boolean
|
||||||
|
): Unit = {
|
||||||
val prevInfos = prev.readSourceInfos().getAllSourceInfos().asScala
|
val prevInfos = prev.readSourceInfos().getAllSourceInfos().asScala
|
||||||
for {
|
for {
|
||||||
(source, infos) <- analysis.readSourceInfos.getAllSourceInfos.asScala
|
(source, infos) <- analysis.readSourceInfos.getAllSourceInfos.asScala
|
||||||
|
|
@ -94,8 +102,9 @@ final class BuildServerReporterImpl(
|
||||||
} {
|
} {
|
||||||
val prevProblems = prevInfos.get(source).map(_.getReportedProblems()).getOrElse(Array.empty)
|
val prevProblems = prevInfos.get(source).map(_.getReportedProblems()).getOrElse(Array.empty)
|
||||||
val dontPublish = prevProblems.length == 0 && infos.getReportedProblems().length == 0
|
val dontPublish = prevProblems.length == 0 && infos.getReportedProblems().length == 0
|
||||||
|
val shouldPublish = reportAllPreviousProblems || !dontPublish
|
||||||
|
|
||||||
if (!dontPublish) {
|
if (shouldPublish) {
|
||||||
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
||||||
val params = PublishDiagnosticsParams(
|
val params = PublishDiagnosticsParams(
|
||||||
textDocument = TextDocumentIdentifier(filePath.toUri),
|
textDocument = TextDocumentIdentifier(filePath.toUri),
|
||||||
|
|
@ -185,7 +194,11 @@ final class BuildServerForwarder(
|
||||||
protected override val underlying: Reporter
|
protected override val underlying: Reporter
|
||||||
) extends BuildServerReporter {
|
) extends BuildServerReporter {
|
||||||
|
|
||||||
override def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit = ()
|
override def sendSuccessReport(
|
||||||
|
analysis: CompileAnalysis,
|
||||||
|
prev: CompileAnalysis,
|
||||||
|
reportAllPreviousProblems: Boolean
|
||||||
|
): Unit = ()
|
||||||
|
|
||||||
override def sendFailureReport(sources: Array[VirtualFile]): Unit = ()
|
override def sendFailureReport(sources: Array[VirtualFile]): Unit = ()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue