Skip to content

Commit

Permalink
bugfix: Don't republish old errors on successful compilation
Browse files Browse the repository at this point in the history
We need to report all problems if a BSP client just connected to the server and never compiled.
`reportAllPreviousProblems` will be set to true in that case.

However, if previously we had an error, which was reverted and got back to the state before the
error, we will get a successfull noop compilation, which will not produce any problems.

In this case we don't want to republish everything again, since diagnostics will contain the
error which was reverted.

Connected to VirtusLab/scala-cli#2226 where CLI always connected anew.
  • Loading branch information
tgodzik committed Sep 10, 2024
1 parent b9170ed commit 2fc06f5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/src/main/scala/bloop/reporter/BspProjectReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,23 @@ final class BspProjectReporter(
): Unit = {
val problemsInPreviousAnalysisPerFile = Reporter.groupProblemsByFile(previousSuccessfulProblems)

/**
* We need to report all problems if a BSP client just connected to the server and never compiled.
* `reportAllPreviousProblems` will be set to true in that case.
*
* However, if previously we had an error, which was reverted and got back to the state before the
* error, we will get a successfull noop compilation, which will not produce any problems.
*
* In this case we don't want to republish everything again, since diagnostics will contain the
* error which was reverted.
*
* Connected to https://github.com/VirtusLab/scala-cli/issues/2226 where CLI always connected anew.
*/
def shouldPublishAllProblems =
reportAllPreviousProblems && !wasPreviousSuccessful && code != bsp.StatusCode.Ok
def mockNoOpCompileEventsAndEnd: Option[CompilationEvent.EndCompilation] = {
recentlyReportProblemsPerFile.foreach {
case (sourceFile, problemsPerFile) if reportAllPreviousProblems =>
case (sourceFile, problemsPerFile) if shouldPublishAllProblems =>
reportAllProblems(sourceFile, problemsPerFile)
case (sourceFile, problemsPerFile) =>
problemsInPreviousAnalysisPerFile.get(sourceFile) match {
Expand Down

0 comments on commit 2fc06f5

Please sign in to comment.