diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc/reporters/Reporter.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/reporters/Reporter.scala | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index b617e7b530..5b576a547d 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -10,59 +10,48 @@ import scala.reflect.internal.util._ /** Report information, warnings and errors. * - * This describes the stable interface for issuing information, warnings and errors. + * This describes the internal interface for issuing information, warnings and errors. * The only abstract method in this class must be info0. + * + * TODO: Move external clients (sbt/ide/partest) to reflect.internal.Reporter + * This interface should be considered private to the compiler. */ -abstract class Reporter { - protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit - +abstract class Reporter extends scala.reflect.internal.Reporter { /** Informational messages. If `!force`, they may be suppressed. */ final def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO, force) /** For sending a message which should not be labeled as a warning/error, * but also shouldn't require -verbose to be visible. */ - def echo(msg: String): Unit = info(NoPosition, msg, force = true) - def echo(pos: Position, msg: String): Unit = info(pos, msg, force = true) - - /** Warnings and errors. */ - def warning(pos: Position, msg: String): Unit = info0(pos, msg, WARNING, force = false) - def error(pos: Position, msg: String): Unit = info0(pos, msg, ERROR, force = false) - - def flush(): Unit = { } + def echo(msg: String): Unit = info(NoPosition, msg, force = true) - // overridden by sbt, IDE - def reset(): Unit = { - INFO.count = 0 - WARNING.count = 0 - ERROR.count = 0 - cancelled = false - } - - object severity extends Enumeration - class Severity(val id: Int) extends severity.Value { - var count: Int = 0 - } - val INFO = new Severity(0) { - override def toString: String = "INFO" - } - val WARNING = new Severity(1) { - override def toString: String = "WARNING" - } - val ERROR = new Severity(2) { - override def toString: String = "ERROR" - } + // overridden by sbt, IDE -- should not be in the reporting interface + // (IDE receives comments from ScaladocAnalyzer using this hook method) + // TODO: IDE should override a hook method in the parser instead + def comment(pos: Position, msg: String): Unit = {} // used by sbt (via unit.cancel) to cancel a compile (see hasErrors) + // TODO: figure out how sbt uses this, come up with a separate interface for controlling the build var cancelled: Boolean = false - // overridden by sbt - def hasErrors: Boolean = ERROR.count > 0 || cancelled + override def hasErrors: Boolean = super.hasErrors || cancelled - // overridden by sbt - def hasWarnings: Boolean = WARNING.count > 0 + override def reset(): Unit = { + super.reset() + cancelled = false + } - // overridden by sbt, IDE -- should move out of this interface - // it's unrelated to reporting (IDE receives comments from ScaladocAnalyzer) - def comment(pos: Position, msg: String): Unit = {} + // the below is copy/pasted from ReporterImpl for now + // partest expects this inner class + // TODO: rework partest to use the scala.reflect.internal interface, + // remove duplication here, and consolidate reflect.internal.{ReporterImpl & ReporterImpl} + class Severity(val id: Int)(name: String) { var count: Int = 0 ; override def toString = name} + object INFO extends Severity(0)("INFO") + object WARNING extends Severity(1)("WARNING") + // reason for copy/paste: this is used by partest (must be a val, not an object) + // TODO: use count(ERROR) in scala.tools.partest.nest.DirectCompiler#errorCount, rather than ERROR.count + lazy val ERROR = new Severity(2)("ERROR") + + def count(severity: Severity): Int = severity.count + def resetCount(severity: Severity): Unit = severity.count = 0 } |