aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/Reporter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-17 18:20:07 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-02-23 00:21:26 +0100
commit9d24583b44e4b59d07d61c5f051c8e9a8a832148 (patch)
tree1bdcbc2cd56f6abcc90296bee26a8efcd5fa4331 /src/dotty/tools/dotc/reporting/Reporter.scala
parent11bd355128fb6e0457f70baea235aaba91deb888 (diff)
downloaddotty-9d24583b44e4b59d07d61c5f051c8e9a8a832148.tar.gz
dotty-9d24583b44e4b59d07d61c5f051c8e9a8a832148.tar.bz2
dotty-9d24583b44e4b59d07d61c5f051c8e9a8a832148.zip
Refactor Diagnostic
Break it out from Reporter and eliminate all dependencies to Context. This is done so that Diagnostics can be part of a public and minimal compiler API.
Diffstat (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala38
1 files changed, 1 insertions, 37 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 272b1880f..95c6d7ae6 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -10,46 +10,10 @@ import collection.mutable
import config.Settings.Setting
import config.Printers
import java.lang.System.currentTimeMillis
-import typer.ErrorReporting.DiagnosticString
import typer.Mode
+import Diagnostic.{ERROR, WARNING, INFO}
object Reporter {
-
- private val ERROR = 2
- private val WARNING = 1
- private val INFO = 0
-
- class Diagnostic(msgFn: => String, val pos: SourcePosition, val level: Int) extends Exception {
- import DiagnosticString._
-
- private var myMsg: String = null
- private var myIsNonSensical: Boolean = false
-
- /** The message to report */
- def msg: String = {
- if (myMsg == null) {
- myMsg = msgFn
- if (myMsg.contains(nonSensicalStartTag)) {
- myIsNonSensical = true
- // myMsg might be composed of several d"..." invocations -> nested nonsensical tags possible
- myMsg = myMsg.replaceAllLiterally(nonSensicalStartTag, "").replaceAllLiterally(nonSensicalEndTag, "")
- }
- }
- myMsg
- }
-
- /** Report in current reporter */
- def report(implicit ctx: Context) = ctx.reporter.report(this)
-
- def isNonSensical = { msg; myIsNonSensical }
- def isSuppressed(implicit ctx: Context): Boolean = !ctx.settings.YshowSuppressedErrors.value && isNonSensical
-
- override def toString = s"$getClass at $pos: $msg"
- override def getMessage() = msg
-
- def checkingStr: String = msgFn
- }
-
class Error(msgFn: => String, pos: SourcePosition) extends Diagnostic(msgFn, pos, ERROR)
class Warning(msgFn: => String, pos: SourcePosition) extends Diagnostic(msgFn, pos, WARNING)
class Info(msgFn: => String, pos: SourcePosition) extends Diagnostic(msgFn, pos, INFO)