Skip to content

Commit 0bf1b28

Browse files
committed
feat: capture diagnostic code from Problem
1 parent 9e4671e commit 0bf1b28

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

backend/src/main/scala/bloop/reporter/Reporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ abstract class Reporter(
9494
case _ =>
9595
val mappedPos = p.position
9696
val problemID = if (p.position.sourceFile.isPresent) nextID() else -1
97-
Problem(problemID, p.severity, p.message, mappedPos, p.category)
97+
Problem(problemID, p.severity, p.message, mappedPos, p.category, p.diagnosticCode())
9898
}
9999
}
100100

frontend/src/main/scala/bloop/logging/BspServerLogger.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ final class BspServerLogger private (
9191
val problemPos = event.problem.position
9292
val problemSeverity = event.problem.severity
9393
val sourceFile = toOption(problemPos.sourceFile())
94-
// TODO: Add code content
94+
val code = toOption(event.problem.diagnosticCode()).map(_.code())
9595

9696
(problemPos, sourceFile) match {
9797
case (ZincInternals.ZincExistsStartPos(startLine, startColumn), Some(file)) =>
@@ -109,7 +109,7 @@ final class BspServerLogger private (
109109
val source = Some("bloop")
110110
val uri = bsp.Uri(file.toPath.toUri)
111111
val severity = bspSeverity(problemSeverity)
112-
val diagnostic = bsp.Diagnostic(pos, Some(severity), None, source, message, None)
112+
val diagnostic = bsp.Diagnostic(pos, Some(severity), code, source, message, None)
113113
val textDocument = bsp.TextDocumentIdentifier(uri)
114114
val buildTargetId = bsp.BuildTargetIdentifier(event.projectUri)
115115
Build.publishDiagnostics.notify(

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Dependencies {
1414
val nailgunCommit = "a2520c1e"
1515

1616
// Keep in sync in BloopComponentCompiler
17-
val zincVersion = "1.6.0"
17+
val zincVersion = "1.7.1"
1818

1919
val bspVersion = "2.0.0-M13"
2020
val javaDebugVersion = "0.21.0+1-7f1080f1"

shared/src/main/scala/bloop/reporter/Problem.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package bloop.reporter
22

3+
import java.util.Optional
4+
35
import xsbti.Severity
46

57
/** Describes a problem (error, warning, message, etc.) given to the reporter. */
@@ -13,12 +15,21 @@ final case class Problem private (
1315
/** Position in the source code where the message was triggered */
1416
position: xsbti.Position,
1517
/** The category of this problem. */
16-
category: String
18+
category: String,
19+
/** Unique code attatched to the diagnostic being reported */
20+
override val diagnosticCode: Optional[xsbti.DiagnosticCode]
1721
) extends xsbti.Problem
1822

1923
object Problem {
2024
def fromZincProblem(problem: xsbti.Problem): Problem = {
21-
Problem(-1, problem.severity(), problem.message(), problem.position(), problem.category())
25+
Problem(
26+
-1,
27+
problem.severity(),
28+
problem.message(),
29+
problem.position(),
30+
problem.category(),
31+
problem.diagnosticCode()
32+
)
2233
}
2334

2435
case class DiagnosticsCount(errors: Long, warnings: Long) {

0 commit comments

Comments
 (0)