summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/reporters
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-08-25 17:33:37 +0000
committerPaul Phillips <paulp@improving.org>2011-08-25 17:33:37 +0000
commitfbb5b57d65d9c786ef618c92165ca1e3a72863ce (patch)
treee655741fdf826293613e9ff334fdcddeb5174ac3 /src/compiler/scala/tools/nsc/reporters
parent006cd779797b2ddd0af8a5fe5ad87671509f106f (diff)
downloadscala-fbb5b57d65d9c786ef618c92165ca1e3a72863ce.tar.gz
scala-fbb5b57d65d9c786ef618c92165ca1e3a72863ce.tar.bz2
scala-fbb5b57d65d9c786ef618c92165ca1e3a72863ce.zip
Made -Xprompt more useful, less crashy and more...
Made -Xprompt more useful, less crashy and more open to showing you the stack trace without aborting. For example, the following would resume compilation after showing the trace. % scala -deprecation -Xprompt -nc -e 'case class Foo' foo.scala:1: warning: case classes without a parameter list have been deprecated; use either case objects or case classes with `()' as parameter list. case class Foo ^ a)bort, s)tack, r)esume: s java.lang.Exception [...] at scala.tools.nsc.ast.parser.Parsers$UnitParser.deprecationWarning(Parsers.scala:207) at scala.tools.nsc.ast.parser.Parsers$Parser.paramClauses(Parsers.scala:2058) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$classDef$1.apply(Parsers.scala:2557) at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$classDef$1.apply(Parsers.scala:2545) No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/reporters')
-rw-r--r--src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
index a6e661c4b4..967b582f11 100644
--- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
+++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala
@@ -93,27 +93,21 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr
print(pos, msg, severity)
}
- def displayPrompt(): Unit = try {
- var continue = true
- while (continue) {
- writer.print("r)esume, a)bort: ")
- writer.flush()
- var line = reader.readLine()
- if (line ne null) {
- line = line.toLowerCase()
- if ("abort" startsWith line)
- abort("user abort")
- if ("resume" startsWith line)
- continue = false
+ def displayPrompt(): Unit = {
+ writer.print("\na)bort, s)tack, r)esume: ")
+ writer.flush()
+ if (reader != null) {
+ val response = reader.read().asInstanceOf[Char].toLower
+ if (response == 'a' || response == 's') {
+ (new Exception).printStackTrace()
+ if (response == 'a')
+ sys exit 1
+
+ writer.print("\n")
+ writer.flush()
}
}
}
- catch {
- case ex: IOException => {
- ex.printStackTrace()
- abort("input read error")
- }
- }
private def abort(msg: String) = throw new Error(msg)
override def flush() { writer.flush() }