print-warnings task for Scala 2.10+ to avoid needing to rerun 'compile' to see deprecation/unchecked warnings

This commit is contained in:
Mark Harrah 2012-03-17 19:31:55 -04:00
parent 8fc5db4a8a
commit 474cd75d06
3 changed files with 29 additions and 0 deletions

View File

@ -24,4 +24,7 @@ public interface AnalysisCallback
public void endSource(File sourcePath);
/** Called when the public API of a source file is extracted. */
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);
}

View File

@ -20,4 +20,5 @@ class TestCallback extends AnalysisCallback
def endSource(source: File) { endedSources += source }
def api(source: File, sourceAPI: xsbti.api.SourceAPI) { apis += ((source, sourceAPI)) }
def problem(pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {}
}

View File

@ -4,6 +4,9 @@
package sbt
import xsbti.{Logger => xLogger, F0}
import xsbti.{Maybe,Position,Problem,Severity}
import java.io.File
abstract class AbstractLogger extends Logger
{
@ -61,6 +64,28 @@ object Logger
}
}
def f0[T](t: =>T): F0[T] = new F0[T] { def apply = t }
def m2o[S](m: Maybe[S]): Option[S] = if(m.isDefined) Some(m.get) else None
def o2m[S](o: Option[S]): Maybe[S] = o match { case Some(v) => Maybe.just(v); case None => Maybe.nothing() }
def position(line0: Option[Integer], content: String, offset0: Option[Integer], pointer0: Option[Integer], pointerSpace0: Option[String], sourcePath0: Option[String], sourceFile0: Option[File]): Position =
new Position {
val line = o2m(line0)
val lineContent = content
val offset = o2m(offset0)
val pointer = o2m(pointer0)
val pointerSpace = o2m(pointerSpace0)
val sourcePath = o2m(sourcePath0)
val sourceFile = o2m(sourceFile0)
}
def problem(pos: Position, msg: String, sev: Severity): Problem =
new Problem
{
val position = pos
val message = msg
val severity = sev
}
}
/** This is intended to be the simplest logging interface for use by code that wants to log.