From 98216be3f3e546fc320ab5182ac5c129707db1ce Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Tue, 10 Jun 2014 16:24:37 +0200 Subject: Move reporting logic into Reporting trait Move code from Global/SymbolTable to separate Reporting traits to start carving out an interface in scala.reflect.internal.Reporting, with internals in scala.tools.nsc. Reporting is mixed into the cake. It contains a nested class PerRunReporting. Should do the same for debugging/logging. The idea is that CompilationUnit and Global forward all reporting to Reporter. The Reporting trait contains these forwarders, and PerRunReporting, which accumulates warning state during a run. In the process, I slightly changed the behavior of `globalError` in reflect.internal.SymbolTable: it used to abort, weirdly. I assume that was dummy behavior to avoid introducing an abstract method. It's immediately overridden in Global, and I couldn't find any other subclasses, so I don't think the behavior in SymbolTable was ever observed. Provide necessary hooks for scala.reflect.macros.Parsers#parse. See scala/reflect/macros/contexts/Parsers.scala's parse method, which overrides the reporter to detect when parsing goes wrong. This should be refactored, but that goes beyond the scope of this PR. Don't pop empty macro context stack. (Ran into this while reworking -Xfatal-warnings logic.) Fix -Xfatal-warnings behavior (and check files): it wasn't meant to influence warning reporting, except for emitting one final error; if necessary to fail the compile (when warnings but no errors were reported). Warnings should stay warnings. This was refactored in fbbbb22946, but we soon seem to have relapsed. An hour of gitfu did not lead to where it went wrong. Must've been a merge. --- src/compiler/scala/tools/nsc/reporters/Reporter.scala | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'src/compiler/scala/tools/nsc/reporters') diff --git a/src/compiler/scala/tools/nsc/reporters/Reporter.scala b/src/compiler/scala/tools/nsc/reporters/Reporter.scala index 1a8794d217..b617e7b530 100644 --- a/src/compiler/scala/tools/nsc/reporters/Reporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/Reporter.scala @@ -53,15 +53,6 @@ abstract class Reporter { override def toString: String = "ERROR" } - private var incompleteHandler: (Position, String) => Unit = null - def incompleteHandled = incompleteHandler != null - def withIncompleteHandler[T](handler: (Position, String) => Unit)(thunk: => T) = { - val saved = incompleteHandler - incompleteHandler = handler - try thunk - finally incompleteHandler = saved - } - // used by sbt (via unit.cancel) to cancel a compile (see hasErrors) var cancelled: Boolean = false @@ -71,12 +62,6 @@ abstract class Reporter { // overridden by sbt def hasWarnings: Boolean = WARNING.count > 0 - // TODO - def incompleteInputError(pos: Position, msg: String): Unit = { - if (incompleteHandled) incompleteHandler(pos, msg) - else error(pos, msg) - } - // overridden by sbt, IDE -- should move out of this interface // it's unrelated to reporting (IDE receives comments from ScaladocAnalyzer) def comment(pos: Position, msg: String): Unit = {} -- cgit v1.2.3