-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Export diagnostics (including unused warnings) to SemanticD…
- Loading branch information
Showing
11 changed files
with
325 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
compiler/src/dotty/tools/dotc/semanticdb/DiagnosticOps.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dotty.tools.dotc.semanticdb | ||
|
||
import dotty.tools.dotc.reporting.Diagnostic | ||
import dotty.tools.dotc.{semanticdb => s} | ||
import dotty.tools.dotc.interfaces.Diagnostic.{ERROR, INFO, WARNING} | ||
import dotty.tools.dotc.core.Contexts.Context | ||
import scala.annotation.internal.sharable | ||
|
||
object DiagnosticOps: | ||
@sharable private val asciiColorCodes = "\u001B\\[[;\\d]*m".r | ||
extension (d: Diagnostic) | ||
def toSemanticDiagnostic: s.Diagnostic = | ||
val severity = d.level match | ||
case ERROR => s.Diagnostic.Severity.ERROR | ||
case WARNING => s.Diagnostic.Severity.WARNING | ||
case INFO => s.Diagnostic.Severity.INFORMATION | ||
case _ => s.Diagnostic.Severity.INFORMATION | ||
val msg = asciiColorCodes.replaceAllIn(d.msg.message, m => "") | ||
s.Diagnostic( | ||
range = Scala3.range(d.pos.span, d.pos.source), | ||
severity = severity, | ||
message = msg | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
object Deprecated/*<-_empty_::Deprecated.*/ { | ||
@deprecated/*->scala::deprecated#*/ def deprecatedMethod/*<-_empty_::Deprecated.deprecatedMethod().*/ = ???/*->scala::Predef.`???`().*/ | ||
def main/*<-_empty_::Deprecated.main().*/ = deprecatedMethod/*->_empty_::Deprecated.deprecatedMethod().*/ | ||
} |
Oops, something went wrong.