From aad82c0521ebf08b759b3080a56451be435c02b3 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 3 Oct 2009 17:17:35 +0000 Subject: Enhanced the previous string length fix to work... Enhanced the previous string length fix to work, and made it possible to enable/disable deprecation warnings on the fly in the repl, like so: settings.deprecation = true --- src/compiler/scala/tools/nsc/Interpreter.scala | 2 +- .../scala/tools/nsc/InterpreterSettings.scala | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/compiler/scala/tools/nsc/Interpreter.scala b/src/compiler/scala/tools/nsc/Interpreter.scala index d34c4a8640..48cc5bc61b 100644 --- a/src/compiler/scala/tools/nsc/Interpreter.scala +++ b/src/compiler/scala/tools/nsc/Interpreter.scala @@ -102,7 +102,7 @@ class Interpreter(val settings: Settings, out: PrintWriter) } /** interpreter settings */ - lazy val isettings = new InterpreterSettings + lazy val isettings = new InterpreterSettings(this) object reporter extends ConsoleReporter(settings, null, out) { override def printMessage(msg: String) { diff --git a/src/compiler/scala/tools/nsc/InterpreterSettings.scala b/src/compiler/scala/tools/nsc/InterpreterSettings.scala index 8675e3d8bd..e274294082 100644 --- a/src/compiler/scala/tools/nsc/InterpreterSettings.scala +++ b/src/compiler/scala/tools/nsc/InterpreterSettings.scala @@ -11,7 +11,7 @@ package scala.tools.nsc * @version 1.0 * @author Lex Spoon, 2007/3/24 **/ -class InterpreterSettings { +class InterpreterSettings(repl: Interpreter) { /** A list of paths where :load should look */ var loadPath = List(".") @@ -22,6 +22,14 @@ class InterpreterSettings { */ var maxPrintString = 2400 + def deprecation_=(x: Boolean) = { + val old = repl.settings.deprecation.value + repl.settings.deprecation.value = x + if (!old && x) println("Enabled -deprecation output.") + else if (old && !x) println("Disabled -deprecation output.") + } + def deprecation: Boolean = repl.settings.deprecation.value + override def toString = "InterpreterSettings {\n" + // " loadPath = " + loadPath + "\n" + @@ -50,7 +58,7 @@ package scala.tools.nsc * @version 1.0 * @author Lex Spoon, 2007/3/24 **/ -class InterpreterSettings { +class InterpreterSettings(repl: Interpreter) { /** A list of paths where :load should look */ var loadPath = List(".") @@ -59,7 +67,15 @@ class InterpreterSettings { * more than this number of characters, then the printout is * truncated. */ - var maxPrintString = 390 + var maxPrintString = 2400 + + def deprecation_=(x: Boolean) = { + val old = repl.settings.deprecation.value + repl.settings.deprecation.value = x + if (!old && x) println("Enabled -deprecation output.") + else if (old && !x) println("Disabled -deprecation output.") + } + def deprecation: Boolean = repl.settings.deprecation.value override def toString = "InterpreterSettings {\n" + -- cgit v1.2.3