Skip to content

Commit 3008ed8

Browse files
committed
Remove ancii color code from SemanticDB
1 parent 4b5d3e7 commit 3008ed8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/semanticdb/DiagnosticOps.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING}
66
import dotty.tools.dotc.core.Contexts.Context
77

88
object DiagnosticOps:
9+
private val asciiColorCodes = "\u001B\\[[;\\d]*m".r
910
extension (d: Diagnostic)
1011
def toSemanticDiagnostic(using Context): s.Diagnostic =
1112
val severity = d.level match
1213
case ERROR => s.Diagnostic.Severity.ERROR
1314
case WARNING => s.Diagnostic.Severity.WARNING
1415
case INFO => s.Diagnostic.Severity.INFORMATION
1516
case _ => s.Diagnostic.Severity.INFORMATION
17+
val msg = asciiColorCodes.replaceAllIn(d.msg.message, m => "")
1618
s.Diagnostic(
1719
range = Scala3.range(d.pos.span, d.pos.source),
1820
severity = severity,
19-
message = d.msg.message
21+
message = msg
2022
)

tests/semanticdb/metac.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ Occurrences:
757757
[2:13..2:29): deprecatedMethod -> _empty_/Deprecated.deprecatedMethod().
758758

759759
Diagnostics:
760-
[2:13..2:29): [warning] method deprecatedMethod in object Deprecated is deprecated
760+
[2:13..2:29): [warning] method deprecatedMethod in object Deprecated is deprecated
761761

762762
expect/Empty.scala
763763
------------------

0 commit comments

Comments
 (0)