diff options
author | Martin Odersky <odersky@gmail.com> | 2013-05-10 16:48:47 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-05-10 16:52:43 +0200 |
commit | aad2d3a71f65e1b542bbfafbf387394331a270ee (patch) | |
tree | 20b71bc654557cd02d3a965d87afdf1a76a2cfa1 /src/dotty/tools/dotc/reporting | |
parent | 5ec2199c4966404d462eb866533dc0589fe7f239 (diff) | |
download | dotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.tar.gz dotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.tar.bz2 dotty-aad2d3a71f65e1b542bbfafbf387394331a270ee.zip |
Refactored and augmented source positions.
Also Implemented ConsoleReporter formatting.
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
4 files changed, 14 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala index 2372485f4..9f191afac 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 util.Positions.SourcePosition +import util.SourcePosition import core.Contexts._ import Reporter.Severity.{Value => Severity, _} import java.io.{ BufferedReader, IOException, PrintWriter } @@ -24,36 +24,28 @@ class ConsoleReporter( /** maximal number of error messages to be printed */ protected def ErrorLimit = 100 - def formatMessage(msg: String, pos: SourcePosition)(implicit ctx: Context) = msg // for now + def printSourceLine(pos: SourcePosition) = + printMessage(pos.lineContents.stripLineEnd) + + def printColumnMarker(pos: SourcePosition) = + if (pos.exists) { writer.print(" " * (pos.column - 1) + "^ ") } /** 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: SourcePosition)(implicit ctx: Context) { - printMessage(formatMessage(msg, pos)) + if (pos.exists) { + printSourceLine(pos) + printColumnMarker(pos) + } + printMessage(msg) } def printMessage(msg: String, severity: Severity, pos: SourcePosition)(implicit ctx: Context) { printMessage(label(severity) + msg, pos) } - /** - * @param pos ... - - def printSourceLine(pos: SourcePosition) { - printMessage(pos.lineContent.stripLineEnd) - printColumnMarker(pos) - } - - /** Prints the column marker of the given position. - * - * @param pos ... - */ - def printColumnMarker(pos: SourcePosition) = - if (pos.isDefined) { printMessage(" " * (pos.column - 1) + "^") } -*/ - /** Prints the number of errors and warnings if their are non-zero. */ def printSummary() { if (count(WARNING) > 0) printMessage(countString(WARNING) + " found") diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 86dfb96d8..15dd288c3 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -3,7 +3,7 @@ package dotc package reporting import core.Contexts._ -import util.Positions._ +import util.{SourcePosition, NoSourcePosition} import util.{SourceFile, NoSource} import core.Decorators.PhaseListDecorator import collection.mutable diff --git a/src/dotty/tools/dotc/reporting/StoreReporter.scala b/src/dotty/tools/dotc/reporting/StoreReporter.scala index 31df36e6f..c5c8580c2 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 util.Positions.SourcePosition +import util.SourcePosition import Reporter.Severity.{Value => Severity} /** diff --git a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala index 704317f23..78c39ac7c 100644 --- a/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala +++ b/src/dotty/tools/dotc/reporting/UniqueMessagePositions.scala @@ -3,8 +3,7 @@ package dotc package reporting import scala.collection.mutable -import util.Positions.SourcePosition -import util.SourceFile +import util.{SourcePosition, SourceFile} import Reporter.Severity.{Value => Severity} import core.Contexts.Context |