Skip to content

Commit 92a9f0e

Browse files
ckipp01adpi2
authored andcommitted
feat: start forwarding diagnosticCode via BSP
This change is a continuation of the work that was done in sbt#6874 to allow the Scala 3 compiler to forward the `diagnosticCode` of an error as well as the other normal things. This change in dotty was merged in scala/scala3#15565 and also backported so it will be in the 3.2.x series release. This change captures the `diagnosticCode` and forwards it on via BSP so that tools like Metals can can use this code. You can see this in the BSP trace now for a diagnostic: For example with some code that contains the following: ```scala val x: Int = "hi" ``` You'll see the code in the BSP diagnostic: ``` "diagnostics": [ { "range": { "start": { "line": 9, "character": 15 }, "end": { "line": 9, "character": 19 } }, "severity": 1, "code": "7", "source": "sbt", "message": "Found: (\u001b[32m\"hi\"\u001b[0m : String)\nRequired: Int\n\nThe following import might make progress towards fixing the problem:\n\n import sourcecode.Text.generate\n\n" } ] ``` Co-authored-by: Adrien Piquerez <[email protected]> Refs: scala/scala3#14904
1 parent 1f29c90 commit 92a9f0e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

main/src/main/scala/sbt/internal/server/BuildServerReporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ final class BuildServerReporterImpl(
201201
Diagnostic(
202202
range,
203203
Option(toDiagnosticSeverity(problem.severity)),
204-
None,
204+
problem.diagnosticCode().toOption.map(_.code),
205205
Option("sbt"),
206206
problem.message
207207
)

0 commit comments

Comments
 (0)