mirror of https://github.com/sbt/sbt.git
move to revised warning interface in the compiler
This commit is contained in:
parent
13e62fd645
commit
99a04466f1
|
|
@ -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 =>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ package xsbti;
|
|||
|
||||
public interface Problem
|
||||
{
|
||||
String category();
|
||||
Severity severity();
|
||||
String message();
|
||||
Position position();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue