mirror of https://github.com/sbt/sbt.git
Don't fire publishDiagnostic if there's no problems both in current and previous compilation
This commit is contained in:
parent
2962b088a0
commit
862d373f02
|
|
@ -2374,10 +2374,11 @@ object Defaults extends BuildCommon {
|
|||
val ci = (compile / compileInputs).value
|
||||
val ping = earlyOutputPing.value
|
||||
val reporter = (compile / bspReporter).value
|
||||
val prevAnalysis = previousCompile.value.analysis.toOption.getOrElse(Analysis.empty)
|
||||
BspCompileTask.compute(bspTargetIdentifier.value, thisProjectRef.value, configuration.value) {
|
||||
task =>
|
||||
// TODO - Should readAnalysis + saveAnalysis be scoped by the compile task too?
|
||||
compileIncrementalTaskImpl(task, s, ci, ping, reporter)
|
||||
compileIncrementalTaskImpl(task, s, ci, ping, reporter, prevAnalysis)
|
||||
}
|
||||
}
|
||||
private val incCompiler = ZincUtil.defaultIncrementalCompiler
|
||||
|
|
@ -2406,7 +2407,8 @@ object Defaults extends BuildCommon {
|
|||
s: TaskStreams,
|
||||
ci: Inputs,
|
||||
promise: PromiseWrap[Boolean],
|
||||
reporter: BuildServerReporter
|
||||
reporter: BuildServerReporter,
|
||||
prev: CompileAnalysis
|
||||
): CompileResult = {
|
||||
lazy val x = s.text(ExportStream)
|
||||
def onArgs(cs: Compilers) = {
|
||||
|
|
@ -2428,7 +2430,7 @@ object Defaults extends BuildCommon {
|
|||
.withSetup(onProgress(setup))
|
||||
try {
|
||||
val result = incCompiler.compile(i, s.log)
|
||||
reporter.sendSuccessReport(result.getAnalysis)
|
||||
reporter.sendSuccessReport(result.getAnalysis, prev)
|
||||
result
|
||||
} catch {
|
||||
case e: Throwable =>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ sealed trait BuildServerReporter extends Reporter {
|
|||
|
||||
protected def publishDiagnostic(problem: Problem): Unit
|
||||
|
||||
def sendSuccessReport(analysis: CompileAnalysis): Unit
|
||||
def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit
|
||||
|
||||
def sendFailureReport(sources: Array[VirtualFile]): Unit
|
||||
|
||||
|
|
@ -86,20 +86,26 @@ final class BuildServerReporterImpl(
|
|||
if (ref.id().contains("<")) None
|
||||
else Some(converter.toPath(ref))
|
||||
|
||||
override def sendSuccessReport(analysis: CompileAnalysis): Unit = {
|
||||
override def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit = {
|
||||
val prevInfos = prev.readSourceInfos().getAllSourceInfos().asScala
|
||||
for {
|
||||
(source, infos) <- analysis.readSourceInfos.getAllSourceInfos.asScala
|
||||
filePath <- toSafePath(source)
|
||||
} {
|
||||
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
||||
val params = PublishDiagnosticsParams(
|
||||
textDocument = TextDocumentIdentifier(filePath.toUri),
|
||||
buildTarget,
|
||||
originId = None,
|
||||
diagnostics.toVector,
|
||||
reset = true
|
||||
)
|
||||
exchange.notifyEvent("build/publishDiagnostics", params)
|
||||
val prevProblems = prevInfos.get(source).map(_.getReportedProblems()).getOrElse(Array.empty)
|
||||
val dontPublish = prevProblems.length == 0 && infos.getReportedProblems().length == 0
|
||||
|
||||
if (!dontPublish) {
|
||||
val diagnostics = infos.getReportedProblems.toSeq.flatMap(toDiagnostic)
|
||||
val params = PublishDiagnosticsParams(
|
||||
textDocument = TextDocumentIdentifier(filePath.toUri),
|
||||
buildTarget,
|
||||
originId = None,
|
||||
diagnostics.toVector,
|
||||
reset = true
|
||||
)
|
||||
exchange.notifyEvent("build/publishDiagnostics", params)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +185,7 @@ final class BuildServerForwarder(
|
|||
protected override val underlying: Reporter
|
||||
) extends BuildServerReporter {
|
||||
|
||||
override def sendSuccessReport(analysis: CompileAnalysis): Unit = ()
|
||||
override def sendSuccessReport(analysis: CompileAnalysis, prev: CompileAnalysis): Unit = ()
|
||||
|
||||
override def sendFailureReport(sources: Array[VirtualFile]): Unit = ()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue