diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-09-16 11:49:41 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:33 +0200 |
commit | 12ac3054bf4288403babb172c125cdc98cfff012 (patch) | |
tree | 978ffdb3a6699edd6a47ca0f86a3055e8baa6d54 /src/dotty/tools/dotc/repl/CompilingInterpreter.scala | |
parent | fb4f8ce66c406bfb6376396ea0521df063b883e9 (diff) | |
download | dotty-12ac3054bf4288403babb172c125cdc98cfff012.tar.gz dotty-12ac3054bf4288403babb172c125cdc98cfff012.tar.bz2 dotty-12ac3054bf4288403babb172c125cdc98cfff012.zip |
Add ability to choose between fancy and non-fancy output
Diffstat (limited to 'src/dotty/tools/dotc/repl/CompilingInterpreter.scala')
-rw-r--r-- | src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index ec2c167ce..70b32a16a 100644 --- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -16,7 +16,7 @@ import scala.collection.mutable.{ListBuffer, HashSet, ArrayBuffer} //import ast.parser.SyntaxAnalyzer import io.{PlainFile, VirtualDirectory} import scala.reflect.io.{PlainDirectory, Directory} -import reporting.{FancyConsoleReporter, Reporter} +import reporting.{ConsoleReporter, FancyConsoleReporter, Reporter} import core.Flags import util.{SourceFile, NameTransformer} import io.ClassPath @@ -117,23 +117,31 @@ class CompilingInterpreter( } } - private def newReporter = new FancyConsoleReporter(Console.in, out) { - override def printMessage(msg: String) = { - if (!delayOutput) { - out.print(/*clean*/(msg) + "\n") - // Suppress clean for now for compiler messages - // Otherwise we will completely delete all references to - // line$object$ module classes. The previous interpreter did not - // have the project because the module class was written without the final `$' - // and therefore escaped the purge. We can turn this back on once - // we drop the final `$' from module classes. - out.flush() - } else { - previousOutput += (/*clean*/(msg) + "\n") - } + private def customPrintMessage(msg: String) = { + if (!delayOutput) { + out.print(/*clean*/(msg) + "\n") + // Suppress clean for now for compiler messages + // Otherwise we will completely delete all references to + // line$object$ module classes. The previous interpreter did not + // have the project because the module class was written without the final `$' + // and therefore escaped the purge. We can turn this back on once + // we drop the final `$' from module classes. + out.flush() + } else { + previousOutput += (/*clean*/(msg) + "\n") } } + private def newReporter(implicit ctx: Context) = + if (ctx.settings.color.value == "never") + new ConsoleReporter(Console.in, out) { + override def printMessage(msg: String) = customPrintMessage(msg) + } + else + new FancyConsoleReporter(Console.in, out) { + override def printMessage(msg: String) = customPrintMessage(msg) + } + /** the previous requests this interpreter has processed */ private val prevRequests = new ArrayBuffer[Request]() |