aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-04-17 09:48:22 +0200
committerMartin Odersky <odersky@gmail.com>2013-04-17 10:16:22 +0200
commitca8dc7ada663e44aafe470944dd17256dbde151c (patch)
treed15939e204042e358e0c83064250f1f18c1c4f25 /src/dotty/tools/dotc/reporting
parente32fedb6844eab11a27e365a570b2033a0f6f78d (diff)
downloaddotty-ca8dc7ada663e44aafe470944dd17256dbde151c.tar.gz
dotty-ca8dc7ada663e44aafe470944dd17256dbde151c.tar.bz2
dotty-ca8dc7ada663e44aafe470944dd17256dbde151c.zip
Scanners added.
Moving Positions, Chars to new packages. Added Source positions. Added untyped trees module. Factored out behavior between typed and untyped trees.
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r--src/dotty/tools/dotc/reporting/ConsoleReporter.scala14
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala30
-rw-r--r--src/dotty/tools/dotc/reporting/StoreReporter.scala6
-rw-r--r--src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala6
4 files changed, 29 insertions, 27 deletions
diff --git a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
index 88fdfa386..2372485f4 100644
--- a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
+++ b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
@@ -3,7 +3,7 @@ package dotc
package reporting
import scala.collection.mutable
-import core.Positions.Position
+import util.Positions.SourcePosition
import core.Contexts._
import Reporter.Severity.{Value => Severity, _}
import java.io.{ BufferedReader, IOException, PrintWriter }
@@ -24,24 +24,24 @@ class ConsoleReporter(
/** maximal number of error messages to be printed */
protected def ErrorLimit = 100
- def formatMessage(msg: String, pos: Position)(implicit ctx: Context) = msg // for now
+ def formatMessage(msg: String, pos: SourcePosition)(implicit ctx: Context) = msg // for now
/** Prints the message. */
def printMessage(msg: String) { writer.print(msg + "\n"); writer.flush() }
/** Prints the message with the given position indication. */
- def printMessage(msg: String, pos: Position)(implicit ctx: Context) {
+ def printMessage(msg: String, pos: SourcePosition)(implicit ctx: Context) {
printMessage(formatMessage(msg, pos))
}
- def printMessage(msg: String, severity: Severity, pos: Position)(implicit ctx: Context) {
+ def printMessage(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context) {
printMessage(label(severity) + msg, pos)
}
/**
* @param pos ...
- def printSourceLine(pos: Position) {
+ def printSourceLine(pos: SourcePosition) {
printMessage(pos.lineContent.stripLineEnd)
printColumnMarker(pos)
}
@@ -50,7 +50,7 @@ class ConsoleReporter(
*
* @param pos ...
*/
- def printColumnMarker(pos: Position) =
+ def printColumnMarker(pos: SourcePosition) =
if (pos.isDefined) { printMessage(" " * (pos.column - 1) + "^") }
*/
@@ -60,7 +60,7 @@ class ConsoleReporter(
if ( count(ERROR) > 0) printMessage(countString(ERROR ) + " found")
}
- override def report(msg: String, severity: Severity, pos: Position)(implicit ctx: Context) {
+ override def report(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context) {
if (severity != ERROR || count(severity) <= ErrorLimit)
printMessage(msg, severity, pos)
if (ctx.settings.prompt.value) displayPrompt()
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 2c892938c..3e7eaecde 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -3,16 +3,16 @@ package dotc
package reporting
import core.Contexts._
-import core.Positions._
+import util.Positions._
+import util.{SourceFile, NoSource}
import core.Decorators.PhaseListDecorator
import collection.mutable
-import io.{SourceFile, NoSource}
import java.lang.System.currentTimeMillis
trait Reporting { this: Context =>
- def error(msg: String, pos: Position = NoPosition): Unit = reporter.error(msg, pos)
- def warning(msg: String, pos: Position = NoPosition): Unit = reporter.warning(msg, pos)
- def inform(msg: String, pos: Position = NoPosition): Unit = reporter.info(msg, pos)
+ def error(msg: String, pos: SourcePosition = NoSourcePosition): Unit = reporter.error(msg, pos)
+ def warning(msg: String, pos: SourcePosition = NoSourcePosition): Unit = reporter.warning(msg, pos)
+ def inform(msg: String, pos: SourcePosition = NoSourcePosition): Unit = reporter.info(msg, pos)
def log(msg: => String): Unit =
if (this.settings.log.value.containsPhase(phase))
@@ -24,6 +24,8 @@ trait Reporting { this: Context =>
def informTime(msg: => String, start: Long): Unit =
informProgress(msg + elapsed(start))
+ def deprecationWarning(msg: String, pos: SourcePosition): Unit = ???
+
private def elapsed(start: Long) =
" in " + (currentTimeMillis - start) + "ms"
@@ -78,9 +80,9 @@ abstract class Reporter {
import Reporter.Severity.{Value => Severity, _}
- protected def report(msg: String, severity: Severity, pos: Position)(implicit ctx: Context): Unit
+ protected def report(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context): Unit
- protected def isHidden(severity: Severity, pos: Position)(implicit ctx: Context) = false
+ protected def isHidden(severity: Severity, pos: SourcePosition)(implicit ctx: Context) = false
val count = new mutable.HashMap[Severity, Int]() {
override def default(key: Severity) = 0
@@ -99,7 +101,7 @@ abstract class Reporter {
finally _truncationOK = saved
}
- type ErrorHandler = (String, Position, Context) => Unit
+ type ErrorHandler = (String, SourcePosition, Context) => Unit
private var incompleteHandler: ErrorHandler = error(_, _)(_)
def withIncompleteHandler[T](handler: ErrorHandler)(op: => T): T = {
val saved = incompleteHandler
@@ -112,26 +114,26 @@ abstract class Reporter {
def hasWarnings = count(WARNING) > 0
/** For sending messages that are printed only if -verbose is set */
- def info(msg: String, pos: Position = NoPosition)(implicit ctx: Context): Unit =
+ def info(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
if (ctx.settings.verbose.value) info0(msg, INFO, pos)
/** 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, pos: Position = NoPosition)(implicit ctx: Context): Unit =
+ def echo(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
info0(msg, INFO, pos)
- def warning(msg: String, pos: Position = NoPosition)(implicit ctx: Context): Unit =
+ def warning(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
if (!ctx.settings.nowarn.value)
withoutTruncating(info0(msg, WARNING, pos))
- def error(msg: String, pos: Position = NoPosition)(implicit ctx: Context): Unit =
+ def error(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
withoutTruncating(info0(msg, ERROR, pos))
- def incompleteInputError(msg: String, pos: Position = NoPosition)(implicit ctx: Context): Unit =
+ def incompleteInputError(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
incompleteHandler(msg, pos, ctx)
- private def info0(msg: String, severity: Severity, pos: Position)(implicit ctx: Context): Unit = {
+ private def info0(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context): Unit = {
if (!isHidden(severity, pos)) {
count(severity) += 1
report(msg, severity, pos)
diff --git a/src/dotty/tools/dotc/reporting/StoreReporter.scala b/src/dotty/tools/dotc/reporting/StoreReporter.scala
index 5b9553509..31df36e6f 100644
--- a/src/dotty/tools/dotc/reporting/StoreReporter.scala
+++ b/src/dotty/tools/dotc/reporting/StoreReporter.scala
@@ -4,7 +4,7 @@ package reporting
import core.Contexts.Context
import scala.collection.mutable
-import core.Positions.Position
+import util.Positions.SourcePosition
import Reporter.Severity.{Value => Severity}
/**
@@ -12,12 +12,12 @@ import Reporter.Severity.{Value => Severity}
*/
class StoreReporter extends Reporter {
- class Info(val msg: String, val severity: Severity, val pos: Position) {
+ class Info(val msg: String, val severity: Severity, val pos: SourcePosition) {
override def toString() = "pos: " + pos + " " + msg + " " + severity
}
val infos = new mutable.LinkedHashSet[Info]
- protected def report(msg: String, severity: Severity, pos: Position)(implicit ctx: Context): Unit = {
+ protected def report(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context): Unit = {
infos += new Info(msg, severity, pos)
}
diff --git a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
index 5df999aab..704317f23 100644
--- a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
+++ b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala
@@ -3,9 +3,9 @@ package dotc
package reporting
import scala.collection.mutable
-import core.Positions.Position
+import util.Positions.SourcePosition
+import util.SourceFile
import Reporter.Severity.{Value => Severity}
-import io.SourceFile
import core.Contexts.Context
/**
@@ -20,7 +20,7 @@ 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(severity: Severity, pos: Position)(implicit ctx: Context): Boolean =
+ override def isHidden(severity: Severity, pos: SourcePosition)(implicit ctx: Context): Boolean =
pos.exists && {
positions get (ctx.source, pos.point) match {
case Some(level) if level >= severity => true