summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-07 01:37:26 +0000
committerPaul Phillips <paulp@improving.org>2010-12-07 01:37:26 +0000
commitd46e72721f578caaaf4d55060c0a1a9d531641e7 (patch)
tree4a163758db044d0edcdf72029ff28d45ae36a7f2
parent7806112e43776fc812c93ec9cabd5cbd1953c4a6 (diff)
downloadscala-d46e72721f578caaaf4d55060c0a1a9d531641e7.tar.gz
scala-d46e72721f578caaaf4d55060c0a1a9d531641e7.tar.bz2
scala-d46e72721f578caaaf4d55060c0a1a9d531641e7.zip
Tired of trying to debug things like classpaths...
Tired of trying to debug things like classpaths only to see output like the following: [search path for class files: /System/classes/you/already/know:/Importan...] I added a "do not truncate" mechanism to reporter and put it to use. Now scala -verbose will let you in on those classpath secrets. No review.
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala6
-rw-r--r--src/compiler/scala/tools/nsc/Interpreter.scala5
-rw-r--r--src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala32
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala1
-rw-r--r--src/compiler/scala/tools/nsc/reporters/Reporter.scala13
5 files changed, 36 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index 261714452d..0f8e039323 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -144,6 +144,7 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
if (opt.fatalWarnings) globalError(msg)
else reporter.warning(NoPosition, msg)
+ def informComplete(msg: String): Unit = reporter.withoutTruncating(inform(msg))
def informProgress(msg: String) = if (opt.verbose) inform("[" + msg + "]")
def inform[T](msg: String, value: T): T = returning(value)(x => inform(msg + x))
def informTime(msg: String, start: Long) = informProgress(msg + " in " + (currentTime - start) + "ms")
@@ -197,8 +198,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable
dependencyAnalysis.loadDependencyAnalysis()
if (opt.verbose || opt.logClasspath) {
- inform("[search path for source files: " + classPath.sourcepaths.mkString(",") + "]")
- inform("[search path for class files: " + classPath.asClasspathString + "]")
+ // Uses the "do not truncate" inform
+ informComplete("[search path for source files: " + classPath.sourcepaths.mkString(",") + "]")
+ informComplete("[search path for class files: " + classPath.asClasspathString + "]")
}
/** Taking flag checking to a somewhat higher level. */
diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala
index 99aa1bcad6..4a502f0068 100644
--- a/src/compiler/scala/tools/nsc/Interpreter.scala
+++ b/src/compiler/scala/tools/nsc/Interpreter.scala
@@ -89,7 +89,10 @@ class Interpreter(val settings: Settings, out: PrintWriter) {
/** reporter */
object reporter extends ConsoleReporter(settings, null, out) {
override def printMessage(msg: String) {
- out println clean(msg)
+ out println (
+ if (truncationOK) clean(msg)
+ else cleanNoTruncate(msg)
+ )
out.flush()
}
}
diff --git a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
index 11ef7ffb68..ccc3cb27dd 100644
--- a/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/AbstractReporter.scala
@@ -22,6 +22,9 @@ abstract class AbstractReporter extends Reporter {
}
val settings: Settings
+ private def isVerbose = settings.verbose.value
+ private def noWarnings = settings.nowarnings.value
+ private def isPromptSet = settings.prompt.value
def display(pos: Position, msg: String, severity: Severity): Unit
def displayPrompt: Unit
@@ -31,27 +34,22 @@ abstract class AbstractReporter extends Reporter {
if (settings.Xwarnfatal.value && _severity == WARNING) ERROR
else _severity
- severity match {
- case INFO =>
- if (force || settings.verbose.value) display(pos, msg, severity)
- case WARNING =>
- val hidden = testAndLog(pos, severity)
- if (!settings.nowarnings.value) {
- if (!hidden || settings.prompt.value) display(pos, msg, severity)
- if (settings.prompt.value) displayPrompt
- }
- case ERROR =>
- val hidden = testAndLog(pos, severity)
- if (!hidden || settings.prompt.value) display(pos, msg, severity)
- if (settings.prompt.value) displayPrompt
+ if (severity == INFO) {
+ if (isVerbose || force)
+ display(pos, msg, severity)
+ }
+ else {
+ val hidden = testAndLog(pos, severity)
+ if (severity == WARNING && noWarnings) ()
+ else {
+ if (!hidden || isPromptSet) display(pos, msg, severity)
+ if (isPromptSet) displayPrompt
+ }
}
}
- /** Logs a position and returns <code>true</code> if it was already logged.
+ /** 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.
- *
- * @param pos ...
- * @return <code>true</code> if <code>pos</code> was already logged.
*/
private def testAndLog(pos: Position, severity: Severity): Boolean =
pos != null && pos.isDefined && {
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index 1f01087dad..722c367863 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -63,7 +63,6 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
printSourceLine(pos)
}
}
-
def print(pos: Position, msg: String, severity: Severity) {
printMessage(pos, clabel(severity) + msg)
}
diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
index 8dcb5183bb..05d76d1006 100644
--- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala
@@ -51,6 +51,19 @@ abstract class Reporter {
}
}
+ /** Whether very long lines can be truncated. This exists so important
+ * debugging information (like printing the classpath) is not rendered
+ * invisible due to the max message length.
+ */
+ private var _truncationOK: Boolean = true
+ def truncationOK = _truncationOK
+ def withoutTruncating[T](body: => T): T = {
+ val saved = _truncationOK
+ _truncationOK = false
+ try body
+ finally _truncationOK = saved
+ }
+
def info(pos: Position, msg: String, force: Boolean) { info0(pos, msg, INFO, force) }
def warning(pos: Position, msg: String ) { info0(pos, msg, WARNING, false) }
def error(pos: Position, msg: String ) { info0(pos, msg, ERROR, false) }