summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-02-09 15:25:31 +0000
committermichelou <michelou@epfl.ch>2007-02-09 15:25:31 +0000
commitcc20f5fbb5321eec19109355eb843545f3b0d453 (patch)
treec453865cd6c9836a7f47e51ce1e7e72572938bc8 /src
parent04cbd87417cc0a0ffae59e434cb8e129d8fbb0eb (diff)
downloadscala-cc20f5fbb5321eec19109355eb843545f3b0d453.tar.gz
scala-cc20f5fbb5321eec19109355eb843545f3b0d453.tar.bz2
scala-cc20f5fbb5321eec19109355eb843545f3b0d453.zip
minor changes in reporters/*.scala
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala45
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala95
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala67
3 files changed, 103 insertions, 104 deletions
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index 734b1527ed..c1c6aee3a3 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -1,9 +1,7 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2002-2007 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
package scala.tools.nsc.reporters
@@ -16,41 +14,40 @@ import nsc.Settings
* This reporter implements filtering.
*/
abstract class AbstractReporter extends Reporter {
- private val positions = new HashSet[Position]();
+ private val positions = new HashSet[Position]()
val settings: Settings
- def display(pos : Position, msg : String, severity : Severity) : Unit
- def displayPrompt : Unit
+ def display(pos: Position, msg: String, severity: Severity): Unit
+ def displayPrompt: Unit
- protected def info0(pos : Position, msg : String, severity : Severity, force : Boolean) : Unit =
+ protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit =
severity match {
- case INFO => if (force || settings.verbose.value) display(pos, msg, severity)
- case WARNING => {
+ case INFO =>
+ if (force || settings.verbose.value) display(pos, msg, severity)
+ case WARNING =>
val hidden = testAndLog(pos)
if (!settings.nowarnings.value) {
if (!hidden || settings.prompt.value) display(pos, msg, severity)
if (settings.prompt.value) displayPrompt
}
- }
- case ERROR => {
- val hidden = testAndLog(pos);
+ case ERROR =>
+ val hidden = testAndLog(pos)
if (!hidden || settings.prompt.value) display(pos, msg, severity)
if (settings.prompt.value) displayPrompt
- }
}
- //########################################################################
- // Private Methods
-
- /** Logs a position and returns true if it was already logged. */
- private def testAndLog(pos : Position) : Boolean = {
+ /** Logs a position and returns <code>true</code> if it was already logged.
+ *
+ * @param pos ...
+ * @return <code>true</code> if <code>pos</code> was already logged.
+ */
+ private def testAndLog(pos: Position): Boolean = {
if (pos eq null) return false
if (pos.column == 0) return false
- if (positions.contains(pos)) return true
- positions += (pos)
+ if (positions contains pos) return true
+ positions += pos
return false
}
- //########################################################################
}
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 547ec9e214..504b91fee3 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -1,57 +1,54 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2002-2007 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
package scala.tools.nsc.reporters
+import java.io.{BufferedReader, InputStreamReader, IOException, PrintWriter}
+
import compat.StringBuilder
import scala.tools.nsc.util.{FakePos, Position}
-import java.io.BufferedReader
-import java.io.InputStreamReader
-import java.io.IOException
-import java.io.PrintWriter
-
/**
* This class implements a Reporter that displays messages on a text
* console.
*/
-class ConsoleReporter(val settings: Settings, reader : BufferedReader, writer : PrintWriter) extends AbstractReporter {
- //########################################################################
- // Public Fields
+class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: PrintWriter) extends AbstractReporter {
/** Whether a short file name should be displayed before errors */
- var shortname : Boolean = false
+ var shortname: Boolean = false
- def label(severity : Severity): String = severity match {
+ private def label(severity: Severity): String = severity match {
case ERROR => "error"
case WARNING => "warning"
case INFO => null
}
- def clabel(severity : Severity) = {
+
+ private def clabel(severity : Severity) = {
val label0 = label(severity)
if (label0 eq null) "" else label0 + ": "
}
-
-
- //########################################################################
- // Public Constructors
def this(settings: Settings) =
this(settings, Console.in, new PrintWriter(Console.err, true))
- //########################################################################
- // Public Methods - Count
-
-
- /** Returns the number of errors issued totally as a string */
- def getCountString(severity : Severity) : String = getCountString0(count(severity), label(severity))
- /** Returns a string meaning "n elements". */
- def getCountString0(n : Int, elements : String) : String =
+ /** Returns the number of errors issued totally as a string.
+ *
+ * @param severity ...
+ * @return ...
+ */
+ private def getCountString(severity: Severity): String =
+ getCountString0(count(severity), label(severity))
+
+ /** Returns a string meaning "n elements".
+ *
+ * @param n ...
+ * @param elements ...
+ * @return ...
+ */
+ private def getCountString0(n: Int, elements: String): String =
n match {
case 0 => "no " + elements + "s"
case 1 => "one " + elements
@@ -61,41 +58,45 @@ class ConsoleReporter(val settings: Settings, reader : BufferedReader, writer :
case _ => "" + n + " " + elements + "s"
}
-
- //########################################################################
- // Public Methods - Print
-
/** Prints the message. */
- def printMessage(msg : String) = writer.println(msg)
+ def printMessage(msg: String) = writer.println(msg)
/** Prints the message with the given position indication. */
- def printMessage(posIn : Position, msg : String) : Unit = {
+ def printMessage(posIn: Position, msg: String): Unit =
if (posIn ne null) {
val pos = posIn.inUltimateSource
val buf = new StringBuilder(msg)
buf.insert(0, " ")
if (pos.line != Position.NOLINE)
- buf.insert(0, ":"+pos.line+":")
+ buf.insert(0, ":" + pos.line + ":")
pos match {
case FakePos(msg) =>
- buf.insert(0,msg)
+ buf.insert(0, msg)
case _ =>
val file = pos.source.file
buf.insert(0, if (shortname) file.name else file.path)
}
printMessage(buf.toString())
printSourceLine(pos)
- } else printMessage(msg)
- }
+ } else
+ printMessage(msg)
- def print(pos : Position, msg : String, severity : Severity) = printMessage(pos, clabel(severity) + msg)
+ def print(pos: Position, msg: String, severity: Severity) =
+ printMessage(pos, clabel(severity) + msg)
- def printSourceLine(pos : Position) = if ((pos ne null) && pos.offset != Position.NOPOS) {
+ /**
+ * @param pos ...
+ */
+ def printSourceLine(pos: Position) = if ((pos ne null) && pos.offset != Position.NOPOS) {
printMessage(pos.lineContent.stripLineEnd)
printColumnMarker(pos)
}
- /** Prints the column marker of the given position. */
- def printColumnMarker(pos : Position) = if (pos ne null) {
+
+ /** Prints the column marker of the given position.
+ *
+ * @param pos ...
+ */
+ def printColumnMarker(pos: Position) = if (pos ne null) {
val buffer = new StringBuilder(pos.column)
var i = 1
while (i < pos.column) {
@@ -112,13 +113,12 @@ class ConsoleReporter(val settings: Settings, reader : BufferedReader, writer :
if ( errors > 0) printMessage(getCountString(ERROR ) + " found")
}
- //########################################################################
- // Public Methods - Display
- def display(pos : Position, msg : String, severity : Severity) : Unit = {
+ def display(pos: Position, msg: String, severity: Severity): Unit = {
incr(severity)
print(pos, msg, severity)
}
- def displayPrompt : Unit = try {
+
+ def displayPrompt: Unit = try {
var continue = true
while (continue) {
writer.print("r)esume, a)bort: ")
@@ -137,4 +137,5 @@ class ConsoleReporter(val settings: Settings, reader : BufferedReader, writer :
throw new Error("input read error")
}
}
+
}
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index cbfab874e4..54690ba03b 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -1,60 +1,61 @@
-/* ____ ____ ____ ____ ______ *\
-** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
-** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
-** /_____/\____/\___/\____/____/ **
-\* */
-
+/* NSC -- new Scala compiler
+ * Copyright 2002-2007 LAMP/EPFL
+ * @author Martin Odersky
+ */
// $Id$
-package scala.tools.nsc.reporters;
-import scala.tools.nsc.util.Position;
+package scala.tools.nsc.reporters
+import scala.tools.nsc.util.Position
/**
* This interface provides methods to issue information, warning and
* error messages.
*/
abstract class Reporter {
- abstract class Severity(val code : Int);
- object INFO extends Severity(0);
- object WARNING extends Severity(1);
- object ERROR extends Severity(2);
+ abstract class Severity(val code: Int)
+ object INFO extends Severity(0)
+ object WARNING extends Severity(1)
+ object ERROR extends Severity(2)
- def reset : Unit = {
- errors = 0;
- warnings = 0;
+ def reset: Unit = {
+ errors = 0
+ warnings = 0
cancelled = false
}
- def count(severity : Severity): Int = severity match {
- case ERROR => errors;
- case WARNING => warnings;
- case INFO => 0;
+
+ def count(severity: Severity): Int = severity match {
+ case ERROR => errors
+ case WARNING => warnings
+ case INFO => 0
}
- def incr(severity : Severity): Unit = severity match {
- case ERROR => errors = errors + 1;
- case WARNING => warnings = warnings + 1;;
+
+ def incr(severity: Severity): Unit = severity match {
+ case ERROR => errors = errors + 1
+ case WARNING => warnings = warnings + 1
case INFO => {}
}
- var errors : Int = 0;
- var warnings : Int = 0;
+ var errors : Int = 0
+ var warnings : Int = 0
var cancelled: boolean = false
def hasErrors: boolean = errors != 0 || cancelled
- protected def info0(pos : Position, msg : String, severity : Severity, force : Boolean) : Unit;
+ protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit
- def info(pos : Position, msg : String, force : Boolean) : Unit = info0(pos, msg, INFO , force);
- def warning(pos : Position, msg : String ) : Unit = info0(pos, msg, WARNING, false);
- def error(pos : Position, msg : String ) : Unit = info0(pos, msg, ERROR, false);
+ def info(pos: Position, msg: String, force: Boolean): Unit = info0(pos, msg, INFO , force)
+ def warning(pos: Position, msg: String ): Unit = info0(pos, msg, WARNING, false)
+ def error(pos: Position, msg: String ): Unit = info0(pos, msg, ERROR, false)
/** An error that could possibly be fixed if the unit were longer.
- * This is used, for example, when the interpreter tries
- * to distinguish fatal errors from those that are due to
- * needing more lines of input from the user. */
- var incompleteInputError: ((Position,String) => Unit) = error
+ * This is used, for example, when the interpreter tries
+ * to distinguish fatal errors from those that are due to
+ * needing more lines of input from the user.
+ */
+ var incompleteInputError: (Position, String) => Unit = error
- def withIncompleteHandler[T](handler: ((Position,String) => Unit))(thunk: =>T) = {
+ def withIncompleteHandler[T](handler: (Position, String) => Unit)(thunk: => T) = {
val savedHandler = incompleteInputError
try {
incompleteInputError = handler