diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-04-20 19:08:36 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-04-20 22:57:41 +0200 |
commit | 89fd256787695774771b5d4509de493271267585 (patch) | |
tree | a58383ca643d0302e4de61d783cabb138a75c7b1 | |
parent | 016bc3db52d6f1ffa3ef2285d5801f82f5f49167 (diff) | |
download | scala-89fd256787695774771b5d4509de493271267585.tar.gz scala-89fd256787695774771b5d4509de493271267585.tar.bz2 scala-89fd256787695774771b5d4509de493271267585.zip |
scala.reflect.api: Reporters => FrontEnds
20 files changed, 146 insertions, 154 deletions
diff --git a/src/compiler/scala/reflect/internal/FrontEnds.scala b/src/compiler/scala/reflect/internal/FrontEnds.scala new file mode 100644 index 0000000000..74501c7686 --- /dev/null +++ b/src/compiler/scala/reflect/internal/FrontEnds.scala @@ -0,0 +1,75 @@ +package scala.reflect +package internal + +trait FrontEnds { self: SymbolTable => + + import scala.tools.nsc.reporters._ + import scala.tools.nsc.Settings + + def mkConsoleFrontEnd(minSeverity: Int = 1): FrontEnd = { + val settings = new Settings() + if (minSeverity <= 0) settings.verbose.value = true + if (minSeverity > 1) settings.nowarn.value = true + wrapReporter(new ConsoleReporter(settings)) + } + + abstract class FrontEndToReporterProxy(val frontEnd: FrontEnd) extends AbstractReporter { + import frontEnd.{Severity => ApiSeverity} + val API_INFO = frontEnd.INFO + val API_WARNING = frontEnd.WARNING + val API_ERROR = frontEnd.ERROR + + type NscSeverity = Severity + val NSC_INFO = INFO + val NSC_WARNING = WARNING + val NSC_ERROR = ERROR + + def display(pos: Position, msg: String, nscSeverity: NscSeverity): Unit = + frontEnd.log(pos, msg, nscSeverity match { + case NSC_INFO => API_INFO + case NSC_WARNING => API_WARNING + case NSC_ERROR => API_ERROR + }) + + def displayPrompt(): Unit = + frontEnd.interactive() + } + + def wrapFrontEnd(frontEnd: FrontEnd): Reporter = new FrontEndToReporterProxy(frontEnd) { + val settings = new Settings() + settings.verbose.value = true + settings.nowarn.value = false + } + + class ReporterToFrontEndProxy(val reporter: Reporter) extends FrontEnd { + val API_INFO = INFO + val API_WARNING = WARNING + val API_ERROR = ERROR + + override def hasErrors = reporter.hasErrors + override def hasWarnings = reporter.hasWarnings + + def display(info: Info): Unit = info.severity match { + case API_INFO => reporter.info(info.pos, info.msg, false) + case API_WARNING => reporter.warning(info.pos, info.msg) + case API_ERROR => reporter.error(info.pos, info.msg) + } + + def interactive(): Unit = reporter match { + case reporter: AbstractReporter => reporter.displayPrompt() + case _ => // do nothing + } + + override def flush(): Unit = { + super.flush() + reporter.flush() + } + + override def reset(): Unit = { + super.reset() + reporter.reset() + } + } + + def wrapReporter(reporter: Reporter): FrontEnd = new ReporterToFrontEndProxy(reporter) +} diff --git a/src/compiler/scala/reflect/internal/Reporters.scala b/src/compiler/scala/reflect/internal/Reporters.scala deleted file mode 100644 index 20d4a1d026..0000000000 --- a/src/compiler/scala/reflect/internal/Reporters.scala +++ /dev/null @@ -1,74 +0,0 @@ -package scala.reflect -package internal - -trait Reporters { self: SymbolTable => - - import self.{Reporter => ApiReporter} - import scala.tools.nsc.reporters._ - import scala.tools.nsc.reporters.{Reporter => NscReporter} - import scala.tools.nsc.Settings - - def mkConsoleReporter(minSeverity: Int = 1): ApiReporter = { - val settings = new Settings() - if (minSeverity <= 0) settings.verbose.value = true - if (minSeverity > 1) settings.nowarn.value = true - wrapNscReporter(new ConsoleReporter(settings)) - } - - abstract class ApiToNscReporterProxy(val apiReporter: ApiReporter) extends AbstractReporter { - import apiReporter.{Severity => ApiSeverity} - val API_INFO = apiReporter.INFO - val API_WARNING = apiReporter.WARNING - val API_ERROR = apiReporter.ERROR - - type NscSeverity = Severity - val NSC_INFO = INFO - val NSC_WARNING = WARNING - val NSC_ERROR = ERROR - - def display(pos: Position, msg: String, nscSeverity: NscSeverity): Unit = - apiReporter.log(pos, msg, nscSeverity match { - case NSC_INFO => API_INFO - case NSC_WARNING => API_WARNING - case NSC_ERROR => API_ERROR - }) - - def displayPrompt(): Unit = - apiReporter.interactive() - } - - def wrapApiReporter(apiReporter: ApiReporter): NscReporter = new ApiToNscReporterProxy(apiReporter) { - val settings = new Settings() - settings.verbose.value = true - settings.nowarn.value = false - } - - class NscToApiReporterProxy(val nscReporter: NscReporter) extends ApiReporter { - val API_INFO = INFO - val API_WARNING = WARNING - val API_ERROR = ERROR - - def display(info: Info): Unit = info.severity match { - case API_INFO => nscReporter.info(info.pos, info.msg, false) - case API_WARNING => nscReporter.warning(info.pos, info.msg) - case API_ERROR => nscReporter.error(info.pos, info.msg) - } - - def interactive(): Unit = nscReporter match { - case nscReporter: AbstractReporter => nscReporter.displayPrompt() - case _ => // do nothing - } - - override def flush(): Unit = { - super.flush() - nscReporter.flush() - } - - override def reset(): Unit = { - super.reset() - nscReporter.reset() - } - } - - def wrapNscReporter(nscReporter: NscReporter): ApiReporter = new NscToApiReporterProxy(nscReporter) -} diff --git a/src/compiler/scala/reflect/internal/SymbolTable.scala b/src/compiler/scala/reflect/internal/SymbolTable.scala index 0688d13ae5..7d9dd282cf 100644 --- a/src/compiler/scala/reflect/internal/SymbolTable.scala +++ b/src/compiler/scala/reflect/internal/SymbolTable.scala @@ -36,7 +36,7 @@ abstract class SymbolTable extends api.Universe with Importers with Required with TreeBuildUtil - with Reporters + with FrontEnds with CapturedVariables with StdAttachments { @@ -53,7 +53,7 @@ abstract class SymbolTable extends api.Universe /** Overridden when we know more about what was happening during a failure. */ def supplementErrorMessage(msg: String): String = msg - + private[scala] def printCaller[T](msg: String)(result: T) = { Console.err.println(msg + ": " + result) Console.err.println("Called from:") diff --git a/src/compiler/scala/reflect/makro/runtime/Context.scala b/src/compiler/scala/reflect/makro/runtime/Context.scala index 184008658e..15a4118b85 100644 --- a/src/compiler/scala/reflect/makro/runtime/Context.scala +++ b/src/compiler/scala/reflect/makro/runtime/Context.scala @@ -10,7 +10,7 @@ abstract class Context extends scala.reflect.makro.Context with Enclosures with Names with Reifiers - with Reporters + with FrontEnds with Settings with Symbols with Typers diff --git a/src/compiler/scala/reflect/makro/runtime/Reporters.scala b/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala index 0fd037bdd2..7cfa8e80f3 100644 --- a/src/compiler/scala/reflect/makro/runtime/Reporters.scala +++ b/src/compiler/scala/reflect/makro/runtime/FrontEnds.scala @@ -1,21 +1,21 @@ package scala.reflect.makro package runtime -trait Reporters { +trait FrontEnds { self: Context => import mirror._ - def reporter: mirror.Reporter = wrapNscReporter(mirror.reporter) + def frontEnd: FrontEnd = wrapReporter(mirror.reporter) - def setReporter(reporter: mirror.Reporter): this.type = { - mirror.reporter = wrapApiReporter(reporter) + def setFrontEnd(frontEnd: FrontEnd): this.type = { + mirror.reporter = wrapFrontEnd(frontEnd) this } - def withReporter[T](reporter: Reporter)(op: => T): T = { + def withFrontEnd[T](frontEnd: FrontEnd)(op: => T): T = { val old = mirror.reporter - setReporter(reporter) + setFrontEnd(frontEnd) try op finally mirror.reporter = old } diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala index 6d832a590f..21a90326cf 100644 --- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala +++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala @@ -16,14 +16,11 @@ import scala.compat.Platform.EOL trait ToolBoxes extends { self: Universe => - import self.{Reporter => ApiReporter} - import scala.tools.nsc.reporters.{Reporter => NscReporter} + def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = "") = new ToolBox(frontEnd, options) - def mkToolBox(reporter: ApiReporter = mkSilentReporter(), options: String = "") = new ToolBox(reporter, options) + class ToolBox(val frontEnd: FrontEnd, val options: String) extends AbsToolBox { - class ToolBox(val reporter: ApiReporter, val options: String) extends AbsToolBox { - - class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter: NscReporter) + class ToolBoxGlobal(settings: scala.tools.nsc.Settings, reporter: Reporter) extends ReflectGlobal(settings, reporter, ToolBox.this.classLoader) { import definitions._ @@ -200,11 +197,7 @@ trait ToolBoxes extends { self: Universe => val run = new Run reporter.reset() run.compileUnits(List(unit), run.namerPhase) - if (reporter.hasErrors) { - var msg = "reflective compilation has failed: " + EOL + EOL - msg += ToolBox.this.reporter.infos map (_.msg) mkString EOL - throw new ToolBoxError(ToolBox.this, msg) - } + throwIfErrors() val className = mdef.symbol.fullName if (settings.debug.value) println("generated: "+className) @@ -250,6 +243,15 @@ trait ToolBoxes extends { self: Universe => settings.Yshowsymkinds.value = saved3 } } + + // reporter doesn't accumulate errors, but the front-end does + def throwIfErrors() = { + if (frontEnd.hasErrors) { + var msg = "reflective compilation has failed: " + EOL + EOL + msg += frontEnd.infos map (_.msg) mkString EOL + throw new ToolBoxError(ToolBox.this, msg) + } + } } // todo. is not going to work with quoted arguments with embedded whitespaces @@ -263,19 +265,13 @@ trait ToolBoxes extends { self: Universe => lazy val compiler: ToolBoxGlobal = { try { - val errorFn: String => Unit = msg => reporter.log(NoPosition, msg, reporter.ERROR) - // [Eugene] settings shouldn't be passed via reporters, this is crazy -// val command = reporter match { -// case reporter: AbstractReporter => new CompilerCommand(arguments.toList, reporter.settings, errorFn) -// case _ => new CompilerCommand(arguments.toList, errorFn) -// } + val errorFn: String => Unit = msg => frontEnd.log(NoPosition, msg, frontEnd.ERROR) val command = new CompilerCommand(arguments.toList, errorFn) command.settings.outputDirs setSingleOutput virtualDirectory - val nscReporter = new ApiToNscReporterProxy(reporter) { val settings = command.settings } - val instance = new ToolBoxGlobal(command.settings, nscReporter) - if (nscReporter.hasErrors) { + val instance = new ToolBoxGlobal(command.settings, new FrontEndToReporterProxy(frontEnd) { val settings = command.settings }) + if (frontEnd.hasErrors) { var msg = "reflective compilation has failed: cannot initialize the compiler: " + EOL + EOL - msg += reporter.infos map (_.msg) mkString EOL + msg += frontEnd.infos map (_.msg) mkString EOL throw new ToolBoxError(this, msg) } instance.phase = (new instance.Run).typerPhase // need to manually set a phase, because otherwise TypeHistory will crash diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 6c038162b3..f9cef385dc 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -11,7 +11,7 @@ import compat.Platform.currentTime import scala.tools.util.{ Profiling, PathResolver } import scala.collection.{ mutable, immutable } import io.{ SourceReader, AbstractFile, Path } -import reporters.{ Reporter => NscReporter, ConsoleReporter } +import reporters.{ Reporter, ConsoleReporter } import util.{ NoPosition, Exceptional, ClassPath, SourceFile, NoSourceFile, Statistics, StatisticsInfo, BatchSourceFile, ScriptSourceFile, ShowPickled, ScalaClassLoader, returning } import scala.reflect.internal.pickling.{ PickleBuffer, PickleFormat } import settings.{ AestheticSettings } @@ -31,17 +31,17 @@ import backend.icode.analysis._ import language.postfixOps import reflect.internal.StdAttachments -class Global(var currentSettings: Settings, var reporter: NscReporter) extends SymbolTable - with ClassLoaders - with ToolBoxes - with CompilationUnits - with Plugins - with PhaseAssembly - with Trees - with FreeVars - with TreePrinters - with DocComments - with Positions { +class Global(var currentSettings: Settings, var reporter: Reporter) extends SymbolTable + with ClassLoaders + with ToolBoxes + with CompilationUnits + with Plugins + with PhaseAssembly + with Trees + with FreeVars + with TreePrinters + with DocComments + with Positions { override def settings = currentSettings @@ -49,7 +49,7 @@ class Global(var currentSettings: Settings, var reporter: NscReporter) extends S // alternate constructors ------------------------------------------ - def this(reporter: NscReporter) = + def this(reporter: Reporter) = this(new Settings(err => reporter.error(null, err)), reporter) def this(settings: Settings) = @@ -1614,7 +1614,7 @@ object Global { * This allows the use of a custom Global subclass with the software which * wraps Globals, such as scalac, fsc, and the repl. */ - def fromSettings(settings: Settings, reporter: NscReporter): Global = { + def fromSettings(settings: Settings, reporter: Reporter): Global = { // !!! The classpath isn't known until the Global is created, which is too // late, so we have to duplicate it here. Classpath is too tightly coupled, // it is a construct external to the compiler and should be treated as such. @@ -1622,7 +1622,7 @@ object Global { val loader = ScalaClassLoader.fromURLs(new PathResolver(settings).result.asURLs, parentLoader) val name = settings.globalClass.value val clazz = Class.forName(name, true, loader) - val cons = clazz.getConstructor(classOf[Settings], classOf[NscReporter]) + val cons = clazz.getConstructor(classOf[Settings], classOf[Reporter]) cons.newInstance(settings, reporter).asInstanceOf[Global] } @@ -1630,7 +1630,7 @@ object Global { /** A global instantiated this way honors -Yglobal-class setting, and * falls back on calling the Global constructor directly. */ - def apply(settings: Settings, reporter: NscReporter): Global = { + def apply(settings: Settings, reporter: Reporter): Global = { val g = ( if (settings.globalClass.isDefault) null else try fromSettings(settings, reporter) catch { case x => diff --git a/src/compiler/scala/tools/nsc/ToolBoxes.scala b/src/compiler/scala/tools/nsc/ToolBoxes.scala index eb298833b8..5b2b5ff5e9 100644 --- a/src/compiler/scala/tools/nsc/ToolBoxes.scala +++ b/src/compiler/scala/tools/nsc/ToolBoxes.scala @@ -4,11 +4,9 @@ import util.ScalaClassLoader trait ToolBoxes { self: Global => - import self.{Reporter => ApiReporter} + def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = "") = new ToolBox(frontEnd, options) - def mkToolBox(reporter: ApiReporter = mkSilentReporter(), options: String = "") = new ToolBox(reporter, options) - - class ToolBox(val reporter: ApiReporter, val options: String) extends AbsToolBox { + class ToolBox(val frontEnd: FrontEnd, val options: String) extends AbsToolBox { def typeCheck(tree0: Tree, pt: Type = WildcardType, freeTypes: Map[FreeType, Type] = Map[FreeType, Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = { val tree = substituteFreeTypes(tree0, freeTypes) val currentTyper = typer @@ -43,7 +41,7 @@ trait ToolBoxes { self: Global => // need to reset the tree, otherwise toolbox will refuse to work with it tree = resetAllAttrs(tree0.duplicate) val imported = importer.importTree(tree) - val toolBox = libraryClasspathMirror.mkToolBox(reporter.asInstanceOf[libraryClasspathMirror.Reporter], options) + val toolBox = libraryClasspathMirror.mkToolBox(frontEnd.asInstanceOf[libraryClasspathMirror.FrontEnd], options) try toolBox.runExpr(imported) catch { case ex: toolBox.ToolBoxError => diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 8e7eeed3cc..b3ed446563 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -7,7 +7,7 @@ package scala.tools.nsc package ast import symtab._ -import reporters.{Reporter => NscReporter} +import reporters._ import util.{Position, NoPosition} import util.DocStrings._ import scala.reflect.internal.Chars._ @@ -21,8 +21,6 @@ trait DocComments { self: Global => var cookedDocComments = Map[Symbol, String]() - def reporter: NscReporter - /** The raw doc comment map */ val docComments = mutable.HashMap[Symbol, DocComment]() diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 13124e6afc..bfcfa5f2b9 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -13,7 +13,6 @@ import scala.sys.BooleanProp import io.VirtualDirectory import scala.tools.nsc.io.AbstractFile import reporters._ -import reporters.{Reporter => NscReporter} import symtab.Flags import scala.reflect.internal.Names import scala.tools.util.PathResolver @@ -282,7 +281,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends protected def createLineManager(classLoader: ClassLoader): Line.Manager = new Line.Manager(classLoader) /** Instantiate a compiler. Overridable. */ - protected def newCompiler(settings: Settings, reporter: NscReporter): ReplGlobal = { + protected def newCompiler(settings: Settings, reporter: Reporter): ReplGlobal = { settings.outputDirs setSingleOutput virtualDirectory settings.exposeEmptyPackage.value = true new Global(settings, reporter) with ReplGlobal diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala index fb85ebeeb0..75b486ca7d 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala @@ -6,7 +6,4 @@ package scala.tools.nsc package symtab -import ast.{Trees, TreePrinters, DocComments} -import util._ - abstract class SymbolTable extends reflect.internal.SymbolTable
\ No newline at end of file diff --git a/src/library/scala/reflect/DummyMirror.scala b/src/library/scala/reflect/DummyMirror.scala index 1fbf36be9d..9607621928 100644 --- a/src/library/scala/reflect/DummyMirror.scala +++ b/src/library/scala/reflect/DummyMirror.scala @@ -161,8 +161,8 @@ class DummyMirror(cl: ClassLoader) extends api.Mirror { def wrappingPos(trees: List[Tree]): Position = notSupported() def wrappingPos(default: Position,trees: List[Tree]): Position = notSupported() - // Members declared in scala.reflect.api.Reporters - def mkConsoleReporter(minSeverity: Int): Reporter = notSupported() + // Members declared in scala.reflect.api.FrontEnds + def mkConsoleFrontEnd(minSeverity: Int): FrontEnd = notSupported() // Members declared in scala.reflect.api.Scopes type Scope = DummyScope.type @@ -471,7 +471,7 @@ class DummyMirror(cl: ClassLoader) extends api.Mirror { } // Members declared in scala.reflect.api.ToolBoxes - def mkToolBox(reporter: Reporter,options: String): AbsToolBox = notSupported() + def mkToolBox(frontEnd: FrontEnd, options: String): AbsToolBox = notSupported() // Members declared in scala.reflect.api.TreeBuildUtil // type TreeGen = DummyTreeGen.type // [Eugene] cannot compile if uncomment this diff --git a/src/library/scala/reflect/DynamicProxy.scala b/src/library/scala/reflect/DynamicProxy.scala index 02872977f5..3ed17fea41 100644 --- a/src/library/scala/reflect/DynamicProxy.scala +++ b/src/library/scala/reflect/DynamicProxy.scala @@ -43,7 +43,7 @@ trait DynamicProxy extends Dynamic{ def applyDynamicNamed( method:String )( args:(String,DynamicReflectBoxed)* ) : Any = { val class_ = dynamicProxyTarget.getClass var i = 0 - val toolbox = mkToolBox(mkConsoleReporter(),"") + val toolbox = mkToolBox(mkConsoleFrontEnd(),"") val symbol = classToType( dynamicProxyTarget.getClass ).member( newTermName(method).encodedName ) if(args.size == 0){ invoke( dynamicProxyTarget, symbol )() diff --git a/src/library/scala/reflect/api/Reporters.scala b/src/library/scala/reflect/api/FrontEnds.scala index b7428e1599..2c1f3feff6 100644 --- a/src/library/scala/reflect/api/Reporters.scala +++ b/src/library/scala/reflect/api/FrontEnds.scala @@ -1,9 +1,9 @@ package scala.reflect package api -trait Reporters { self: Universe => +trait FrontEnds { self: Universe => - trait Reporter { + trait FrontEnd { object severity extends Enumeration class Severity(val id: Int) extends severity.Value { var count: Int = 0 @@ -18,6 +18,9 @@ trait Reporters { self: Universe => val WARNING = new Severity(1) val ERROR = new Severity(2) + def hasErrors = ERROR.count > 0 + def hasWarnings = WARNING.count > 0 + case class Info(val pos: Position, val msg: String, val severity: Severity) val infos = new collection.mutable.LinkedHashSet[Info] @@ -46,14 +49,14 @@ trait Reporters { self: Universe => } } - class SilentReporter extends Reporter { + class SilentFrontEnd extends FrontEnd { def display(info: Info) {} def interactive() {} } /** Creates a UI-less reporter that simply accumulates all the messages */ - def mkSilentReporter(): Reporter = new SilentReporter() + def mkSilentFrontEnd(): FrontEnd = new SilentFrontEnd() /** Creates a reporter that prints messages to the console according to the settings. * @@ -61,5 +64,5 @@ trait Reporters { self: Universe => * 0 stands for INFO, 1 stands for WARNING and 2 stands for ERROR. */ // todo. untangle warningsAsErrors from Reporters. I don't feel like moving this flag here! - def mkConsoleReporter(minSeverity: Int = 1): Reporter + def mkConsoleFrontEnd(minSeverity: Int = 1): FrontEnd }
\ No newline at end of file diff --git a/src/library/scala/reflect/api/ToolBoxes.scala b/src/library/scala/reflect/api/ToolBoxes.scala index 387ef5163b..aefd6b511c 100644 --- a/src/library/scala/reflect/api/ToolBoxes.scala +++ b/src/library/scala/reflect/api/ToolBoxes.scala @@ -5,17 +5,17 @@ trait ToolBoxes { self: Universe => type ToolBox <: AbsToolBox - def mkToolBox(reporter: Reporter = mkSilentReporter(), options: String = ""): AbsToolBox + def mkToolBox(frontEnd: FrontEnd = mkSilentFrontEnd(), options: String = ""): AbsToolBox // [Eugene] what do you think about the interface? namely about the ``freeTypes'' part. trait AbsToolBox { - /** UI of the toolbox. + /** Front end of the toolbox. * * Accumulates and displays warnings and errors, can drop to interactive mode (if supported). * The latter can be useful to study the typechecker or to debug complex macros. */ - def reporter: Reporter + def frontEnd: FrontEnd /** Typechecks a tree using this ToolBox. * This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings. diff --git a/src/library/scala/reflect/api/Universe.scala b/src/library/scala/reflect/api/Universe.scala index d1f546608e..2b22839d39 100755 --- a/src/library/scala/reflect/api/Universe.scala +++ b/src/library/scala/reflect/api/Universe.scala @@ -19,7 +19,7 @@ abstract class Universe extends Symbols with ClassLoaders with TreeBuildUtil with ToolBoxes - with Reporters + with FrontEnds with Importers { /** Given an expression, generate a tree that when compiled and executed produces the original tree. diff --git a/src/library/scala/reflect/makro/Context.scala b/src/library/scala/reflect/makro/Context.scala index 5ce801e2e6..b304d98a5a 100644 --- a/src/library/scala/reflect/makro/Context.scala +++ b/src/library/scala/reflect/makro/Context.scala @@ -12,7 +12,7 @@ trait Context extends Aliases with Infrastructure with Names with Reifiers - with Reporters + with FrontEnds with Settings with Symbols with Typers diff --git a/src/library/scala/reflect/makro/Reporters.scala b/src/library/scala/reflect/makro/FrontEnds.scala index 7341b0e0b7..a1e24dcea3 100644 --- a/src/library/scala/reflect/makro/Reporters.scala +++ b/src/library/scala/reflect/makro/FrontEnds.scala @@ -1,14 +1,14 @@ package scala.reflect.makro -trait Reporters { +trait FrontEnds { self: Context => import mirror._ /** Exposes means to control the compiler UI */ - def reporter: Reporter - def setReporter(reporter: Reporter): this.type - def withReporter[T](reporter: Reporter)(op: => T): T + def frontEnd: FrontEnd + def setFrontEnd(frontEnd: FrontEnd): this.type + def withFrontEnd[T](frontEnd: FrontEnd)(op: => T): T /** For sending a message which should not be labeled as a warning/error, * but also shouldn't require -verbose to be visible. diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala index fd244b40ec..1da9a6bc16 100644 --- a/test/files/run/toolbox_console_reporter.scala +++ b/test/files/run/toolbox_console_reporter.scala @@ -1,10 +1,10 @@ import scala.reflect.mirror._ object Test extends App { - // todo. cannot test this unfortunately, because ConsoleReporter grabs Console.out too early + // todo. cannot test this unfortunately, because ConsoleFrontEnd grabs Console.out too early // todo. and isn't affected by Console.setOut employed by partest to intercept output - //val toolbox = mkToolBox(reporter = mkConsoleReporter(), options = "-deprecation") + //val toolbox = mkToolBox(frontEnd = mkConsoleFrontEnd(), options = "-deprecation") //toolbox.runExpr(reify{ // object Utils { // @deprecated("test", "2.10.0") diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala index 7e9259946b..5f264f7d74 100644 --- a/test/files/run/toolbox_silent_reporter.scala +++ b/test/files/run/toolbox_silent_reporter.scala @@ -11,6 +11,6 @@ object Test extends App { Utils.foo }) println("============compiler messages============") - toolbox.reporter.infos.foreach(println(_)) + toolbox.frontEnd.infos.foreach(println(_)) println("=========================================") }
\ No newline at end of file |