diff --git a/compile/LoggerReporter.scala b/compile/LoggerReporter.scala index 85db4ee44..9fd586d8a 100644 --- a/compile/LoggerReporter.scala +++ b/compile/LoggerReporter.scala @@ -115,7 +115,7 @@ class LoggerReporter(maximumErrors: Int, log: Logger) extends xsbti.Reporter def log(pos: Position, msg: String, severity: Severity): Unit = { - allProblems += problem(pos, msg, severity) + allProblems += problem("", pos, msg, severity) severity match { case Warn | Error => diff --git a/compile/inc/Compile.scala b/compile/inc/Compile.scala index 6b3761ca0..2187ae740 100644 --- a/compile/inc/Compile.scala +++ b/compile/inc/Compile.scala @@ -63,11 +63,11 @@ private final class AnalysisCallback(internalMap: File => Option[File], external private def add[A,B](map: Map[A,Set[B]], a: A, b: B): Unit = map.getOrElseUpdate(a, new HashSet[B]) += b - def problem(pos: Position, msg: String, severity: Severity, reported: Boolean): Unit = + def problem(category: String, pos: Position, msg: String, severity: Severity, reported: Boolean): Unit = { for(source <- m2o(pos.sourceFile)) { val map = if(reported) reporteds else unreporteds - map.getOrElseUpdate(source, ListBuffer.empty) += Logger.problem(pos, msg, severity) + map.getOrElseUpdate(source, ListBuffer.empty) += Logger.problem(category, pos, msg, severity) } } diff --git a/compile/interface/CompilerInterface.scala b/compile/interface/CompilerInterface.scala index 0c0488b72..c0110af5a 100644 --- a/compile/interface/CompilerInterface.scala +++ b/compile/interface/CompilerInterface.scala @@ -84,7 +84,7 @@ private final class CachedCompiler0(args: Array[String], initialLog: WeakLog) ex } finally { compiler.clear() } - dreporter.problems foreach { p => callback.problem(p.position, p.message, p.severity, true) } + dreporter.problems foreach { p => callback.problem(p.category, p.position, p.message, p.severity, true) } } dreporter.printSummary() if(!noErrors(dreporter)) handleErrors(dreporter, log) @@ -96,10 +96,14 @@ private final class CachedCompiler0(args: Array[String], initialLog: WeakLog) ex } def processUnreportedWarnings(run: compiler.Run) { - implicit def listToBoolean[T](l: List[T]): Boolean = error("source compatibility only, should never be called") - implicit def listToInt[T](l: List[T]): Int = error("source compatibility only, should never be called") - compiler.logUnreportedWarnings(run.deprecationWarnings) - compiler.logUnreportedWarnings(run.uncheckedWarnings) + // allConditionalWarnings and the ConditionalWarning class are only in 2.10+ + final class CondWarnCompat(val what: String, val warnings: mutable.ListBuffer[(compiler.Position, String)]) + implicit def compat(run: AnyRef): Compat = new Compat + final class Compat { def allConditionalWarnings = List[CondWarnCompat]() } + + val warnings = run.allConditionalWarnings + if(!warnings.isEmpty) + compiler.logUnreportedWarnings(warnings.map(cw => ("" /*cw.what*/, cw.warnings.toList))) } object compiler extends CallbackGlobal(command.settings, dreporter) { @@ -149,13 +153,12 @@ private final class CachedCompiler0(args: Array[String], initialLog: WeakLog) ex meth.setAccessible(true) meth.invoke(this) } - def logUnreportedWarnings(seq: List[(Position,String)]): Unit = // Scala 2.10.x and later + def logUnreportedWarnings(seq: Seq[(String, List[(Position,String)])]): Unit = // Scala 2.10.x and later { - for( (pos, msg) <- seq) yield - callback.problem(reporter.asInstanceOf[DelegatingReporter].convert(pos), msg, Severity.Warn, false) + val drep = reporter.asInstanceOf[DelegatingReporter] + for( (what, warnings) <- seq; (pos, msg) <- warnings) yield + callback.problem(what, drep.convert(pos), msg, Severity.Warn, false) } - def logUnreportedWarnings(count: Boolean): Unit = () // for source compatibility with Scala 2.8.x - def logUnreportedWarnings(count: Int): Unit = () // for source compatibility with Scala 2.9.x def set(callback: AnalysisCallback, dreporter: DelegatingReporter) { diff --git a/compile/persist/AnalysisFormats.scala b/compile/persist/AnalysisFormats.scala index e1fec5237..6b6dc2798 100644 --- a/compile/persist/AnalysisFormats.scala +++ b/compile/persist/AnalysisFormats.scala @@ -53,7 +53,7 @@ object AnalysisFormats wrap[SourceInfo, (Seq[Problem],Seq[Problem])](si => (si.reportedProblems, si.unreportedProblems), { case (a,b) => SourceInfos.makeInfo(a,b)}) implicit def problemFormat(implicit posF: Format[Position], msgF: Format[String], sevF: Format[Severity]): Format[Problem] = - asProduct3(problem _)( p => (p.position, p.message, p.severity)) + asProduct4(problem _)( p => (p.category, p.position, p.message, p.severity)) implicit def positionFormat: Format[Position] = asProduct7( position _ )( p => (m2o(p.line), p.lineContent, m2o(p.offset), m2o(p.pointer), m2o(p.pointerSpace), m2o(p.sourcePath), m2o(p.sourceFile))) diff --git a/interface/src/main/java/xsbti/AnalysisCallback.java b/interface/src/main/java/xsbti/AnalysisCallback.java index 2ba6f6c83..c23b43ecd 100644 --- a/interface/src/main/java/xsbti/AnalysisCallback.java +++ b/interface/src/main/java/xsbti/AnalysisCallback.java @@ -26,5 +26,5 @@ public interface AnalysisCallback public void api(File sourceFile, xsbti.api.SourceAPI source); /** Provides problems discovered during compilation. These may be reported (logged) or unreported. * Unreported problems are usually unreported because reporting was not enabled via a command line switch. */ - public void problem(Position pos, String msg, Severity severity, boolean reported); + public void problem(String what, Position pos, String msg, Severity severity, boolean reported); } \ No newline at end of file diff --git a/interface/src/main/java/xsbti/Problem.java b/interface/src/main/java/xsbti/Problem.java index cf2641900..db7f67b22 100644 --- a/interface/src/main/java/xsbti/Problem.java +++ b/interface/src/main/java/xsbti/Problem.java @@ -5,6 +5,7 @@ package xsbti; public interface Problem { + String category(); Severity severity(); String message(); Position position(); diff --git a/util/log/Logger.scala b/util/log/Logger.scala index 1f6d4d3a5..7715b80db 100644 --- a/util/log/Logger.scala +++ b/util/log/Logger.scala @@ -79,9 +79,10 @@ object Logger val sourceFile = o2m(sourceFile0) } - def problem(pos: Position, msg: String, sev: Severity): Problem = + def problem(cat: String, pos: Position, msg: String, sev: Severity): Problem = new Problem { + val category = cat val position = pos val message = msg val severity = sev