diff --git a/interface/src/main/java/xsbti/AnalysisCallback.java b/interface/src/main/java/xsbti/AnalysisCallback.java index 53a33253b..2ba6f6c83 100644 --- a/interface/src/main/java/xsbti/AnalysisCallback.java +++ b/interface/src/main/java/xsbti/AnalysisCallback.java @@ -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); } \ No newline at end of file diff --git a/interface/src/test/scala/TestCallback.scala b/interface/src/test/scala/TestCallback.scala index 6621a40ef..95fcbf96c 100644 --- a/interface/src/test/scala/TestCallback.scala +++ b/interface/src/test/scala/TestCallback.scala @@ -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) {} } \ No newline at end of file diff --git a/util/log/Logger.scala b/util/log/Logger.scala index 04babcc4e..1f6d4d3a5 100644 --- a/util/log/Logger.scala +++ b/util/log/Logger.scala @@ -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.