mirror of https://github.com/sbt/sbt.git
more flexible scalac logging
the custom scalac Reporter now delegates to an instance of an sbt interface called xsbti.Reporter handling compilation logging is now mainly done on the sbt-side of the compiler interface the xsbti.Reporter interface provides access to richer information about errors and warnings, including source file, line, and offset xsbti.Reporter can be implemented by users to get access to detailed information without needing to parse the logging output the CompileFailed exception that is thrown when compilation fails now includes an array of the problems, providing detailed error and warning information that can, for example, be consumed by doing a mapFailure on 'compile' and using 'Compile.allProblems'
This commit is contained in:
parent
7dca038bde
commit
6402a766b5
|
|
@ -3,4 +3,5 @@ package xsbti;
|
|||
public abstract class CompileFailed extends RuntimeException
|
||||
{
|
||||
public abstract String[] arguments();
|
||||
public abstract Problem[] problems();
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
/** Intended as a lightweight carrier for scala.Option. */
|
||||
public abstract class Maybe<t>
|
||||
{
|
||||
// private pending Scala bug #3642
|
||||
protected Maybe() {}
|
||||
|
||||
public static <s> Maybe<s> just(final s v)
|
||||
{
|
||||
return new Maybe<s>() {
|
||||
public boolean isDefined() { return true; }
|
||||
public s get() { return v; }
|
||||
};
|
||||
}
|
||||
public static <s> Maybe<s> nothing()
|
||||
{
|
||||
return new Maybe<s>() {
|
||||
public boolean isDefined() { return false; }
|
||||
public s get() { throw new UnsupportedOperationException("nothing.get"); }
|
||||
};
|
||||
}
|
||||
|
||||
public final boolean isEmpty() { return !isDefined(); }
|
||||
public abstract boolean isDefined();
|
||||
public abstract t get();
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
public interface Position
|
||||
{
|
||||
Maybe<Integer> line();
|
||||
String lineContent();
|
||||
Maybe<Integer> offset();
|
||||
|
||||
// pointer to the column position of the error/warning
|
||||
Maybe<Integer> pointer();
|
||||
Maybe<String> pointerSpace();
|
||||
|
||||
Maybe<String> sourcePath();
|
||||
Maybe<java.io.File> sourceFile();
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
public interface Problem
|
||||
{
|
||||
Severity severity();
|
||||
String message();
|
||||
Position position();
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
public interface Reporter
|
||||
{
|
||||
/** Resets logging, including any accumulated errors, warnings, messages, and counts.*/
|
||||
public void reset();
|
||||
/** Returns true if this logger has seen any errors since the last call to reset.*/
|
||||
public boolean hasErrors();
|
||||
/** Returns true if this logger has seen any warnings since the last call to reset.*/
|
||||
public boolean hasWarnings();
|
||||
/** Logs a summary of logging since the last reset.*/
|
||||
public void printSummary();
|
||||
/** Returns a list of warnings and errors since the last reset.*/
|
||||
public Problem[] problems();
|
||||
/** Logs a message.*/
|
||||
public void log(Position pos, String msg, Severity sev);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/* sbt -- Simple Build Tool
|
||||
* Copyright 2008, 2009, 2010 Mark Harrah
|
||||
*/
|
||||
package xsbti;
|
||||
|
||||
public enum Severity
|
||||
{
|
||||
Info, Warn, Error
|
||||
}
|
||||
Loading…
Reference in New Issue