aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-09-16 13:34:57 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-10 13:25:33 +0200
commit18a69f7bd230bc06696e41be53a6735aa6e94ccc (patch)
treec21f0dc527194048b2195f2a1c4d98b1149cd3cf /src/dotty/tools/dotc/reporting
parent12ac3054bf4288403babb172c125cdc98cfff012 (diff)
downloaddotty-18a69f7bd230bc06696e41be53a6735aa6e94ccc.tar.gz
dotty-18a69f7bd230bc06696e41be53a6735aa6e94ccc.tar.bz2
dotty-18a69f7bd230bc06696e41be53a6735aa6e94ccc.zip
Rename Diagnostic to diagnostic.Message
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r--src/dotty/tools/dotc/reporting/ConsoleReporter.scala19
-rw-r--r--src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala7
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala43
-rw-r--r--src/dotty/tools/dotc/reporting/StoreReporter.scala13
-rw-r--r--src/dotty/tools/dotc/reporting/ThrowingReporter.scala7
-rw-r--r--src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala13
-rw-r--r--src/dotty/tools/dotc/reporting/diagnostic/Diagnostic.scala (renamed from src/dotty/tools/dotc/reporting/Diagnostic.scala)9
7 files changed, 64 insertions, 47 deletions
diff --git a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
index 1d9423b70..1ed889683 100644
--- a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
+++ b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
@@ -8,6 +8,7 @@ import core.Contexts._
import Reporter._
import java.io.{ BufferedReader, IOException, PrintWriter }
import scala.reflect.internal.util._
+import diagnostic.Message
/**
* This class implements a Reporter that displays messages on a text
@@ -40,17 +41,17 @@ class ConsoleReporter(
}
}
- override def doReport(d: Diagnostic)(implicit ctx: Context): Unit = d match {
- case d: Error =>
- printMessageAndPos(d.message, d.pos, d.kind)
+ override def doReport(m: Message)(implicit ctx: Context): Unit = m match {
+ case m: Error =>
+ printMessageAndPos(m.message, m.pos, m.kind)
if (ctx.settings.prompt.value) displayPrompt()
- case d: ConditionalWarning if !d.enablingOption.value =>
- case d: MigrationWarning =>
- printMessageAndPos(d.message, d.pos, d.kind)
- case d: Warning =>
- printMessageAndPos(d.message, d.pos, d.kind)
+ case m: ConditionalWarning if !m.enablingOption.value =>
+ case m: MigrationWarning =>
+ printMessageAndPos(m.message, m.pos, m.kind)
+ case m: Warning =>
+ printMessageAndPos(m.message, m.pos, m.kind)
case _ =>
- printMessageAndPos(d.message, d.pos, d.kind)
+ printMessageAndPos(m.message, m.pos, m.kind)
}
def displayPrompt(): Unit = {
diff --git a/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
index a325fe9f7..140777275 100644
--- a/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
+++ b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
@@ -3,6 +3,7 @@ package dotc
package reporting
import core.Contexts.Context
+import diagnostic.Message
/**
* This trait implements `isHidden` so that we avoid reporting non-sensical messages.
@@ -11,9 +12,9 @@ trait HideNonSensicalMessages extends Reporter {
/** Hides non-sensical messages, unless we haven't reported any error yet or
* `-Yshow-suppressed-errors` is set.
*/
- override def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean =
- super.isHidden(d) || {
- d.isNonSensical &&
+ override def isHidden(m: Message)(implicit ctx: Context): Boolean =
+ super.isHidden(m) || {
+ m.isNonSensical &&
hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
!ctx.settings.YshowSuppressedErrors.value
}
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index db0922b2e..8c9308ba5 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -13,36 +13,47 @@ import java.lang.System.currentTimeMillis
import core.Mode
import interfaces.Diagnostic.{ERROR, WARNING, INFO}
import dotty.tools.dotc.core.Symbols.Symbol
+import diagnostic.Message
import ErrorMessages._
object Reporter {
- class Error(msgFn: => String, pos: SourcePosition, kind: String = "Error") extends Diagnostic(msgFn, pos, ERROR, kind)
- class Warning(msgFn: => String, pos: SourcePosition, kind: String = "Warning") extends Diagnostic(msgFn, pos, WARNING, kind)
- class Info(msgFn: => String, pos: SourcePosition, kind: String = "Info") extends Diagnostic(msgFn, pos, INFO, kind)
+ class Error(msgFn: => String, pos: SourcePosition, kind: String = "Error")
+ extends Message(msgFn, pos, ERROR, kind)
- abstract class ConditionalWarning(msgFn: => String, pos: SourcePosition, kind: String) extends Warning(msgFn, pos, kind) {
+ class Warning(msgFn: => String, pos: SourcePosition, kind: String = "Warning")
+ extends Message(msgFn, pos, WARNING, kind)
+
+ class Info(msgFn: => String, pos: SourcePosition, kind: String = "Info")
+ extends Message(msgFn, pos, INFO, kind)
+
+ abstract class ConditionalWarning(msgFn: => String, pos: SourcePosition, kind: String)
+ extends Warning(msgFn, pos, kind) {
def enablingOption(implicit ctx: Context): Setting[Boolean]
}
- class FeatureWarning(msgFn: => String, pos: SourcePosition, kind: String = "Feature Warning") extends ConditionalWarning(msgFn, pos, kind) {
+ class FeatureWarning(msgFn: => String, pos: SourcePosition, kind: String = "Feature Warning")
+ extends ConditionalWarning(msgFn, pos, kind) {
def enablingOption(implicit ctx: Context) = ctx.settings.feature
}
- class UncheckedWarning(msgFn: => String, pos: SourcePosition, kind: String = "Unchecked Warning") extends ConditionalWarning(msgFn, pos, kind) {
+ class UncheckedWarning(msgFn: => String, pos: SourcePosition, kind: String = "Unchecked Warning")
+ extends ConditionalWarning(msgFn, pos, kind) {
def enablingOption(implicit ctx: Context) = ctx.settings.unchecked
}
- class DeprecationWarning(msgFn: => String, pos: SourcePosition, kind: String = "Deprecation Warning") extends ConditionalWarning(msgFn, pos, kind) {
+ class DeprecationWarning(msgFn: => String, pos: SourcePosition, kind: String = "Deprecation Warning")
+ extends ConditionalWarning(msgFn, pos, kind) {
def enablingOption(implicit ctx: Context) = ctx.settings.deprecation
}
- class MigrationWarning(msgFn: => String, pos: SourcePosition, kind: String = "Migration Warning") extends ConditionalWarning(msgFn, pos, kind) {
+ class MigrationWarning(msgFn: => String, pos: SourcePosition, kind: String = "Migration Warning") extends
+ ConditionalWarning(msgFn, pos, kind) {
def enablingOption(implicit ctx: Context) = ctx.settings.migration
}
/** Convert a SimpleReporter into a real Reporter */
def fromSimpleReporter(simple: interfaces.SimpleReporter): Reporter =
new Reporter with UniqueMessagePositions with HideNonSensicalMessages {
- override def doReport(d: Diagnostic)(implicit ctx: Context): Unit = d match {
- case d: ConditionalWarning if !d.enablingOption.value =>
+ override def doReport(m: Message)(implicit ctx: Context): Unit = m match {
+ case m: ConditionalWarning if !m.enablingOption.value =>
case _ =>
- simple.report(d)
+ simple.report(m)
}
}
}
@@ -211,7 +222,7 @@ trait Reporting { this: Context =>
abstract class Reporter extends interfaces.ReporterResult {
/** Report a diagnostic */
- def doReport(d: Diagnostic)(implicit ctx: Context): Unit
+ def doReport(d: Message)(implicit ctx: Context): Unit
/** Whether very long lines can be truncated. This exists so important
* debugging information (like printing the classpath) is not rendered
@@ -226,7 +237,7 @@ abstract class Reporter extends interfaces.ReporterResult {
finally _truncationOK = saved
}
- type ErrorHandler = Diagnostic => Context => Unit
+ type ErrorHandler = Message => Context => Unit
private var incompleteHandler: ErrorHandler = d => c => report(d)(c)
def withIncompleteHandler[T](handler: ErrorHandler)(op: => T): T = {
val saved = incompleteHandler
@@ -255,7 +266,7 @@ abstract class Reporter extends interfaces.ReporterResult {
override def default(key: String) = 0
}
- def report(d: Diagnostic)(implicit ctx: Context): Unit =
+ def report(d: Message)(implicit ctx: Context): Unit =
if (!isHidden(d)) {
doReport(d)(ctx.addMode(Mode.Printing))
d match {
@@ -269,7 +280,7 @@ abstract class Reporter extends interfaces.ReporterResult {
}
}
- def incomplete(d: Diagnostic)(implicit ctx: Context): Unit =
+ def incomplete(d: Message)(implicit ctx: Context): Unit =
incompleteHandler(d)(ctx)
@@ -302,7 +313,7 @@ abstract class Reporter extends interfaces.ReporterResult {
}
/** Should this diagnostic not be reported at all? */
- def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean = ctx.mode.is(Mode.Printing)
+ def isHidden(m: Message)(implicit ctx: Context): Boolean = ctx.mode.is(Mode.Printing)
/** Does this reporter contain not yet reported errors or warnings? */
def hasPending: Boolean = false
diff --git a/src/dotty/tools/dotc/reporting/StoreReporter.scala b/src/dotty/tools/dotc/reporting/StoreReporter.scala
index b7b7c1af0..dd5935f4c 100644
--- a/src/dotty/tools/dotc/reporting/StoreReporter.scala
+++ b/src/dotty/tools/dotc/reporting/StoreReporter.scala
@@ -6,24 +6,25 @@ import core.Contexts.Context
import collection.mutable
import Reporter.{Error, Warning}
import config.Printers.typr
+import diagnostic.Message
/**
* This class implements a Reporter that stores all messages
*/
class StoreReporter(outer: Reporter) extends Reporter {
- private var infos: mutable.ListBuffer[Diagnostic] = null
+ private var infos: mutable.ListBuffer[Message] = null
- def doReport(d: Diagnostic)(implicit ctx: Context): Unit = {
- typr.println(s">>>> StoredError: ${d.message}") // !!! DEBUG
+ def doReport(m: Message)(implicit ctx: Context): Unit = {
+ typr.println(s">>>> StoredError: ${m.message}") // !!! DEBUG
if (infos == null) infos = new mutable.ListBuffer
- infos += d
+ infos += m
}
override def hasPending: Boolean = infos != null && {
infos exists {
- case d: Error => true
- case d: Warning => true
+ case _: Error => true
+ case _: Warning => true
case _ => false
}
}
diff --git a/src/dotty/tools/dotc/reporting/ThrowingReporter.scala b/src/dotty/tools/dotc/reporting/ThrowingReporter.scala
index 026453036..25adc6a41 100644
--- a/src/dotty/tools/dotc/reporting/ThrowingReporter.scala
+++ b/src/dotty/tools/dotc/reporting/ThrowingReporter.scala
@@ -4,6 +4,7 @@ package reporting
import core.Contexts.Context
import collection.mutable
+import diagnostic.Message
import Reporter._
/**
@@ -11,8 +12,8 @@ import Reporter._
* info to the underlying reporter.
*/
class ThrowingReporter(reportInfo: Reporter) extends Reporter {
- def doReport(d: Diagnostic)(implicit ctx: Context): Unit = d match {
- case _: Error => throw d
- case _ => reportInfo.doReport(d)
+ def doReport(m: Message)(implicit ctx: Context): Unit = m match {
+ case _: Error => throw m
+ case _ => reportInfo.doReport(m)
}
}
diff --git a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
index 32554e6b6..1ef8b3447 100644
--- a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
+++ b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
@@ -5,6 +5,7 @@ package reporting
import scala.collection.mutable
import util.{SourcePosition, SourceFile}
import core.Contexts.Context
+import diagnostic.Message
/**
* This trait implements `isHidden` so that multiple messages per position
@@ -17,12 +18,12 @@ trait UniqueMessagePositions extends Reporter {
/** Logs a position and returns true if it was already logged.
* @note Two positions are considered identical for logging if they have the same point.
*/
- override def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean =
- super.isHidden(d) || {
- d.pos.exists && {
- positions get (ctx.source, d.pos.point) match {
- case Some(level) if level >= d.level => true
- case _ => positions((ctx.source, d.pos.point)) = d.level; false
+ override def isHidden(m: Message)(implicit ctx: Context): Boolean =
+ super.isHidden(m) || {
+ m.pos.exists && {
+ positions get (ctx.source, m.pos.point) match {
+ case Some(level) if level >= m.level => true
+ case _ => positions((ctx.source, m.pos.point)) = m.level; false
}
}
}
diff --git a/src/dotty/tools/dotc/reporting/Diagnostic.scala b/src/dotty/tools/dotc/reporting/diagnostic/Diagnostic.scala
index d08636802..230c1edc0 100644
--- a/src/dotty/tools/dotc/reporting/Diagnostic.scala
+++ b/src/dotty/tools/dotc/reporting/diagnostic/Diagnostic.scala
@@ -1,19 +1,20 @@
package dotty.tools
package dotc
package reporting
+package diagnostic
import util.SourcePosition
import java.util.Optional
-object Diagnostic {
+object Message {
val nonSensicalStartTag = "<nonsensical>"
val nonSensicalEndTag = "</nonsensical>"
}
-class Diagnostic(msgFn: => String, val pos: SourcePosition, val level: Int, val kind: String)
- extends Exception with interfaces.Diagnostic {
- import Diagnostic._
+class Message(msgFn: => String, val pos: SourcePosition, val level: Int, val kind: String)
+extends Exception with interfaces.Diagnostic {
+ import Message._
private var myMsg: String = null
private var myIsNonSensical: Boolean = false