Remove all interface classes except for the ones used by the logger.

This commit is contained in:
Eugene Yokota 2015-08-20 00:38:50 -04:00
parent 81a79826d6
commit 7cbcb67dfa
29 changed files with 6 additions and 657 deletions

View File

@ -109,7 +109,7 @@ lazy val utilComplete = (project in utilPath / "complete").
// logging
lazy val utilLogging = (project in utilPath / "log").
dependsOn(utilInterface/*, processProj*/).
dependsOn(utilInterface).
settings(
testedBaseSettings,
name := "Util Logging",
@ -118,7 +118,6 @@ lazy val utilLogging = (project in utilPath / "log").
// Relation
lazy val utilRelation = (project in utilPath / "relation").
dependsOn(utilInterface/*, processProj*/).
settings(
testedBaseSettings,
name := "Util Relation"

View File

@ -1,62 +0,0 @@
/* sbt -- Simple Build Tool
* Copyright 2008, 2009 Mark Harrah
*/
package xsbti;
import java.io.File;
public interface AnalysisCallback
{
/** Called to indicate that the source file <code>source</code> depends on the source file
* <code>dependsOn</code>. Note that only source files included in the current compilation will
* passed to this method. Dependencies on classes generated by sources not in the current compilation will
* be passed as class dependencies to the classDependency method.
* If <code>publicInherited</code> is true, this dependency is a result of inheritance by a
* template accessible outside of the source file.
* @deprecated Use `sourceDependency(File dependsOn, File source, DependencyContext context)` instead. */
@Deprecated
void sourceDependency(File dependsOn, File source, boolean publicInherited);
/** Called to indicate that the source file <code>source</code> depends on the source file
* <code>dependsOn</code>. Note that only source files included in the current compilation will
* passed to this method. Dependencies on classes generated by sources not in the current compilation will
* be passed as class dependencies to the classDependency method.
* <code>context</code> gives information about the context in which this dependency has been extracted.
* See xsbti.DependencyContext for the list of existing dependency contexts. */
void sourceDependency(File dependsOn, File source, DependencyContext context);
/** Called to indicate that the source file <code>source</code> depends on the top-level
* class named <code>name</code> from class or jar file <code>binary</code>.
* If <code>publicInherited</code> is true, this dependency is a result of inheritance by a
* template accessible outside of the source file.
* @deprecated Use `binaryDependency(File binary, String name, File source, DependencyContext context)` instead. */
@Deprecated
void binaryDependency(File binary, String name, File source, boolean publicInherited);
/** Called to indicate that the source file <code>source</code> depends on the top-level
* class named <code>name</code> from class or jar file <code>binary</code>.
* <code>context</code> gives information about the context in which this dependency has been extracted.
* See xsbti.DependencyContext for the list of existing dependency contexts. */
void binaryDependency(File binary, String name, File source, DependencyContext context);
/** Called to indicate that the source file <code>source</code> produces a class file at
* <code>module</code> contain class <code>name</code>.*/
void generatedClass(File source, File module, String name);
/** Called when the public API of a source file is extracted. */
void api(File sourceFile, xsbti.api.SourceAPI source);
void usedName(File sourceFile, String names);
/** 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. */
void problem(String what, Position pos, String msg, Severity severity, boolean reported);
/**
* Determines whether method calls through this interface should be interpreted as serving
* name hashing algorithm needs in given compiler run.
*
* In particular, it indicates whether member reference and inheritance dependencies should be
* extracted.
*
* As the signature suggests, this method's implementation is meant to be side-effect free. It's added
* to AnalysisCallback because it indicates how other callback calls should be interpreted by both
* implementation of AnalysisCallback and it's clients.
*
* NOTE: This method is an implementation detail and can be removed at any point without deprecation.
* Do not depend on it, please.
*/
boolean nameHashing();
}

View File

@ -1,9 +0,0 @@
package xsbti;
public final class ArtifactInfo
{
public static final String ScalaOrganization = "org.scala-lang";
public static final String ScalaLibraryID = "scala-library";
public static final String ScalaCompilerID = "scala-compiler";
public static final String SbtOrganization = "org.scala-sbt";
}

View File

@ -1,9 +0,0 @@
package xsbti;
/**
* An exception thrown when compilation cancellation has been requested during
* Scala compiler run.
*/
public abstract class CompileCancelled extends RuntimeException {
public abstract String[] arguments();
}

View File

@ -1,7 +0,0 @@
package xsbti;
public abstract class CompileFailed extends RuntimeException
{
public abstract String[] arguments();
public abstract Problem[] problems();
}

View File

@ -1,22 +0,0 @@
package xsbti;
/**
* Enumeration of existing dependency contexts.
* Dependency contexts represent the various kind of dependencies that
* can exist between symbols.
*/
public enum DependencyContext {
/**
* Represents a direct dependency between two symbols :
* object Foo
* object Bar { def foo = Foo }
*/
DependencyByMemberRef,
/**
* Represents an inheritance dependency between two symbols :
* class A
* class B extends A
*/
DependencyByInheritance
}

View File

@ -1,22 +0,0 @@
/* 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.*/
void reset();
/** Returns true if this logger has seen any errors since the last call to reset.*/
boolean hasErrors();
/** Returns true if this logger has seen any warnings since the last call to reset.*/
boolean hasWarnings();
/** Logs a summary of logging since the last reset.*/
void printSummary();
/** Returns a list of warnings and errors since the last reset.*/
Problem[] problems();
/** Logs a message.*/
void log(Position pos, String msg, Severity sev);
/** Reports a comment. */
void comment(Position pos, String msg);
}

View File

@ -1,26 +0,0 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package xsbti.api;
import java.io.ObjectStreamException;
public abstract class AbstractLazy<T> implements Lazy<T>, java.io.Serializable
{
private Object writeReplace() throws ObjectStreamException
{
return new StrictLazy<T>(get());
}
private static final class StrictLazy<T> implements Lazy<T>, java.io.Serializable
{
private final T value;
StrictLazy(T t)
{
value = t;
}
public T get()
{
return value;
}
}
}

View File

@ -1,9 +0,0 @@
/* sbt -- Simple Build Tool
* Copyright 2010 Mark Harrah
*/
package xsbti.api;
public interface Lazy<T>
{
T get();
}

View File

@ -1,83 +0,0 @@
package xsbti.api;
public final class Modifiers implements java.io.Serializable
{
private static final int AbstractBit = 0;
private static final int OverrideBit = 1;
private static final int FinalBit = 2;
private static final int SealedBit = 3;
private static final int ImplicitBit = 4;
private static final int LazyBit = 5;
private static final int MacroBit = 6;
private static int flag(boolean set, int bit)
{
return set ? (1 << bit) : 0;
}
public Modifiers(boolean isAbstract, boolean isOverride, boolean isFinal, boolean isSealed, boolean isImplicit, boolean isLazy, boolean isMacro)
{
this.flags = (byte)(
flag(isAbstract, AbstractBit) |
flag(isOverride, OverrideBit) |
flag(isFinal, FinalBit) |
flag(isSealed, SealedBit) |
flag(isImplicit, ImplicitBit) |
flag(isLazy, LazyBit) |
flag(isMacro, MacroBit)
);
}
private final byte flags;
private boolean flag(int bit)
{
return (flags & (1 << bit)) != 0;
}
public final byte raw()
{
return flags;
}
public final boolean isAbstract()
{
return flag(AbstractBit);
}
public final boolean isOverride()
{
return flag(OverrideBit);
}
public final boolean isFinal()
{
return flag(FinalBit);
}
public final boolean isSealed()
{
return flag(SealedBit);
}
public final boolean isImplicit()
{
return flag(ImplicitBit);
}
public final boolean isLazy()
{
return flag(LazyBit);
}
public final boolean isMacro()
{
return flag(MacroBit);
}
public boolean equals(Object o)
{
return (o instanceof Modifiers) && flags == ((Modifiers)o).flags;
}
public int hashCode()
{
return flags;
}
public String toString()
{
return "Modifiers(" + "isAbstract: " + isAbstract() + ", " + "isOverride: " + isOverride() + ", " + "isFinal: " + isFinal() + ", " + "isSealed: " + isSealed() + ", " + "isImplicit: " + isImplicit() + ", " + "isLazy: " + isLazy() + ", " + "isMacro: " + isMacro()+ ")";
}
}

View File

@ -1,13 +0,0 @@
package xsbti.compile;
import xsbti.AnalysisCallback;
import xsbti.Logger;
import xsbti.Reporter;
import java.io.File;
public interface CachedCompiler
{
/** Returns an array of arguments representing the nearest command line equivalent of a call to run but without the command name itself.*/
String[] commandArguments(File[] sources);
void run(File[] sources, DependencyChanges cpChanges, AnalysisCallback callback, Logger log, Reporter delegate, CompileProgress progress);
}

View File

@ -1,10 +0,0 @@
package xsbti.compile;
import xsbti.Logger;
import xsbti.Reporter;
public interface CachedCompilerProvider
{
ScalaInstance scalaInstance();
CachedCompiler newCachedCompiler(String[] arguments, Output output, Logger log, Reporter reporter, boolean resident);
}

View File

@ -1,29 +0,0 @@
package xsbti.compile;
/**
* Configures modifications to the classpath based on the Scala instance used for compilation.
* This is typically used for the Scala compiler only and all values set to false for the Java compiler.
*/
public interface ClasspathOptions
{
/** If true, includes the Scala library on the boot classpath. This should usually be true.*/
boolean bootLibrary();
/** If true, includes the Scala compiler on the standard classpath.
* This is typically false and is instead managed by the build tool or environment.
*/
boolean compiler();
/** If true, includes extra jars from the Scala instance on the standard classpath.
* This is typically false and is instead managed by the build tool or environment.
*/
boolean extra();
/** If true, automatically configures the boot classpath. This should usually be true.*/
boolean autoBoot();
/** If true, the Scala library jar is filtered from the standard classpath.
* This should usually be true because the library should be included on the boot classpath of the Scala compiler and not the standard classpath.
*/
boolean filterLibrary();
}

View File

@ -1,34 +0,0 @@
package xsbti.compile;
/**
* Defines the order in which Scala and Java sources are compiled when compiling a set of sources with both Java and Scala sources.
* This setting has no effect if only Java sources or only Scala sources are being compiled.
* It is generally more efficient to use JavaThenScala or ScalaThenJava when mixed compilation is not required.
*/
public enum CompileOrder
{
/**
* Allows Scala sources to depend on Java sources and allows Java sources to depend on Scala sources.
*
* In this mode, both Java and Scala sources are passed to the Scala compiler, which generates class files for the Scala sources.
* Then, Java sources are passed to the Java compiler, which generates class files for the Java sources.
* The Scala classes compiled in the first step are included on the classpath to the Java compiler.
*/
Mixed,
/**
* Allows Scala sources to depend on the Java sources in the compilation, but does not allow Java sources to depend on Scala sources.
*
* In this mode, both Java and Scala sources are passed to the Scala compiler, which generates class files for the Scala sources.
* Then, Java sources are passed to the Java compiler, which generates class files for the Java sources.
* The Scala classes compiled in the first step are included on the classpath to the Java compiler.
*/
JavaThenScala,
/**
* Allows Java sources to depend on the Scala sources in the compilation, but does not allow Scala sources to depend on Java sources.
*
* In this mode, both Java and Scala sources are passed to the Scala compiler, which generates class files for the Scala sources.
* Then, Java sources are passed to the Java compiler, which generates class files for the Java sources.
* The Scala classes compiled in the first step are included on the classpath to the Java compiler.
*/
ScalaThenJava
}

View File

@ -1,12 +0,0 @@
package xsbti.compile;
/**
* An API for reporting when files are being compiled.
*
* Note; This is tied VERY SPECIFICALLY to scala.
*/
public interface CompileProgress {
void startUnit(String phase, String unitPath);
boolean advance(int current, int total);
}

View File

@ -1,8 +0,0 @@
package xsbti.compile;
public interface Compilers<ScalaCompiler>
{
JavaCompiler javac();
// should be cached by client if desired
ScalaCompiler scalac();
}

View File

@ -1,12 +0,0 @@
package xsbti.compile;
/**
* Determines if an entry on a classpath contains a class.
*/
public interface DefinesClass
{
/**
* Returns true if the classpath entry contains the requested class.
*/
boolean apply(String className);
}

View File

@ -1,13 +0,0 @@
package xsbti.compile;
import java.io.File;
// only includes changes to dependencies outside of the project
public interface DependencyChanges
{
boolean isEmpty();
// class files or jar files
File[] modifiedBinaries();
// class names
String[] modifiedClasses();
}

View File

@ -1,13 +0,0 @@
package xsbti.compile;
import xsbti.Logger;
import xsbti.Reporter;
/**
* An interface which lets us know how to retrieve cached compiler instances form the current JVM.
*/
public interface GlobalsCache
{
CachedCompiler apply(String[] args, Output output, boolean forceNew, CachedCompilerProvider provider, Logger log, Reporter reporter);
void clear();
}

View File

@ -1,71 +0,0 @@
package xsbti.compile;
import xsbti.Logger;
import java.io.File;
/*
* This API is subject to change.
*
* It is the client's responsibility to:
* 1. Manage class loaders. Usually the client will want to:
* i. Keep the class loader used by the ScalaInstance warm.
* ii. Keep the class loader of the incremental recompilation classes (xsbti.compile) warm.
* iii. Share the class loader for Scala classes between the incremental compiler implementation and the ScalaInstance where possible (must be binary compatible)
* 2. Manage the compiler interface jar. The interface must be compiled against the exact Scala version used for compilation and a compatible Java version.
* 3. Manage compilation order between different compilations.
* i. Execute a compilation for each dependency, obtaining an Analysis for each.
* ii. Provide the Analysis from previous compilations to dependent compilations in the analysis map.
* 4. Provide an implementation of JavaCompiler for compiling Java sources.
* 5. Define a function that determines if a classpath entry contains a class (Setup.definesClass).
* i. This is provided by the client so that the client can cache this information across compilations when compiling multiple sets of sources.
* ii. The cache should be cleared for each new compilation run or else recompilation will not properly account for changes to the classpath.
* 6. Provide a cache directory.
* i. This directory is used by IncrementalCompiler to persist data between compilations.
* ii. It should be a different directory for each set of sources being compiled.
* 7. Manage parallel execution.
* i. Each compilation may be performed in a different thread as long as the dependencies have been compiled already.
* ii. Implementations of all types should be immutable and arrays treated as immutable.
* 8. Ensure general invariants:
* i. The implementations of all types are immutable, except for the already discussed Setup.definesClass.
* ii. Arrays are treated as immutable.
* iii. No value is ever null.
*/
public interface IncrementalCompiler<Analysis, ScalaCompiler>
{
/**
* Performs an incremental compilation as configured by `in`.
* The returned Analysis should be provided to compilations depending on the classes from this compilation.
*/
Analysis compile(Inputs<Analysis, ScalaCompiler> in, Logger log);
/**
* Creates a compiler instance that can be used by the `compile` method.
*
* @param instance The Scala version to use
* @param interfaceJar The compiler interface jar compiled for the Scala version being used
* @param options Configures how arguments to the underlying Scala compiler will be built.
*
*/
@Deprecated
ScalaCompiler newScalaCompiler(ScalaInstance instance, File interfaceJar, ClasspathOptions options, Logger log);
/**
* Creates a compiler instance that can be used by the `compile` method.
*
* @param instance The Scala version to use
* @param interfaceJar The compiler interface jar compiled for the Scala version being used
* @param options Configures how arguments to the underlying Scala compiler will be built.
*/
ScalaCompiler newScalaCompiler(ScalaInstance instance, File interfaceJar, ClasspathOptions options);
/**
* Compiles the source interface for a Scala version. The resulting jar can then be used by the `newScalaCompiler` method
* to create a ScalaCompiler for incremental compilation. It is the client's responsibility to manage compiled jars for
* different Scala versions.
*
* @param label A brief name describing the source component for use in error messages
* @param sourceJar The jar file containing the compiler interface sources. These are published as sbt's compiler-interface-src module.
* @param targetJar Where to create the output jar file containing the compiled classes.
* @param instance The ScalaInstance to compile the compiler interface for.
* @param log The logger to use during compilation. */
void compileInterfaceJar(String label, File sourceJar, File targetJar, File interfaceJar, ScalaInstance instance, Logger log);
}

View File

@ -1,14 +0,0 @@
package xsbti.compile;
/** Configures a single compilation of a single set of sources.*/
public interface Inputs<Analysis,ScalaCompiler>
{
/** The Scala and Java compilers to use for compilation.*/
Compilers<ScalaCompiler> compilers();
/** Standard compilation options, such as the sources and classpath to use. */
Options options();
/** Configures incremental compilation.*/
Setup<Analysis> setup();
}

View File

@ -1,27 +0,0 @@
package xsbti.compile;
import java.io.File;
import xsbti.Logger;
import xsbti.Reporter;
/**
* Interface to a Java compiler.
*/
public interface JavaCompiler
{
/** Compiles Java sources using the provided classpath, output directory, and additional options.
* Output should be sent to the provided logger.
*
* @deprecated 0.13.8 - Use compileWithReporter instead
*/
@Deprecated
void compile(File[] sources, File[] classpath, Output output, String[] options, Logger log);
/**
* Compiles java sources using the provided classpath, output directory and additional options.
*
* Output should be sent to the provided logger.
* Failures should be passed to the provided Reporter.
*/
void compileWithReporter(File[] sources, File[] classpath, Output output, String[] options, Reporter reporter, Logger log);
}

View File

@ -1,20 +0,0 @@
package xsbti.compile;
import java.io.File;
public interface MultipleOutput extends Output {
interface OutputGroup {
/** The directory where source files are stored for this group.
* Source directories should uniquely identify the group for a source file. */
File sourceDirectory();
/** The directory where class files should be generated.
* Incremental compilation will manage the class files in this directory.
* In particular, outdated class files will be deleted before compilation.
* It is important that this directory is exclusively used for one set of sources. */
File outputDirectory();
}
OutputGroup[] outputGroups();
}

View File

@ -1,27 +0,0 @@
package xsbti.compile;
import java.io.File;
/** Standard compilation options.*/
public interface Options
{
/** The classpath to use for compilation.
* This will be modified according to the ClasspathOptions used to configure the ScalaCompiler.*/
File[] classpath();
/** All sources that should be recompiled.
* This should include Scala and Java sources, which are identified by their extension. */
File[] sources();
/** Output for the compilation. */
Output output();
/** The options to pass to the Scala compiler other than the sources and classpath to use. */
String[] options();
/** The options to pass to the Java compiler other than the sources and classpath to use. */
String[] javacOptions();
/** Controls the order in which Java and Scala sources are compiled.*/
CompileOrder order();
}

View File

@ -1,7 +0,0 @@
package xsbti.compile;
/** Abstract interface denoting the output of the compilation. Inheritors are SingleOutput with a global output directory and
* MultipleOutput that specifies the output directory per source file.
*/
public interface Output
{
}

View File

@ -1,37 +0,0 @@
package xsbti.compile;
import java.io.File;
/**
* Defines Scala instance, which is a reference version String, a unique version String, a set of jars, and a class loader for a Scala version.
*
* Note that in this API a 'jar' can actually be any valid classpath entry.
*/
public interface ScalaInstance
{
/** The version used to refer to this Scala version.
* It need not be unique and can be a dynamic version like 2.10.0-SNAPSHOT.
*/
String version();
/** A class loader providing access to the classes and resources in the library and compiler jars. */
ClassLoader loader();
/**@deprecated Only `jars` can be reliably provided for modularized Scala. (Since 0.13.0) */
@Deprecated
File libraryJar();
/**@deprecated Only `jars` can be reliably provided for modularized Scala. (Since 0.13.0) */
@Deprecated
File compilerJar();
/**@deprecated Only `jars` can be reliably provided for modularized Scala. (Since 0.13.0) */
@Deprecated
File[] otherJars();
/** All jar files provided by this Scala instance.*/
File[] allJars();
/** The unique identifier for this Scala instance. An implementation should usually obtain this from the compiler.properties file in the compiler jar. */
String actualVersion();
}

View File

@ -1,47 +0,0 @@
package xsbti.compile;
import java.io.File;
import java.util.Map;
import xsbti.Maybe;
import xsbti.Reporter;
/** Configures incremental recompilation. */
public interface Setup<Analysis>
{
/** Provides the Analysis for the given classpath entry.*/
Maybe<Analysis> analysisMap(File file);
/** Provides a function to determine if classpath entry `file` contains a given class.
* The returned function should generally cache information about `file`, such as the list of entries in a jar.
*/
DefinesClass definesClass(File file);
/** If true, no sources are actually compiled and the Analysis from the previous compilation is returned.*/
boolean skip();
/** The file used to cache information across compilations.
* This file can be removed to force a full recompilation.
* The file should be unique and not shared between compilations. */
File cacheFile();
GlobalsCache cache();
/** If returned, the progress that should be used to report scala compilation to. */
Maybe<CompileProgress> progress();
/** The reporter that should be used to report scala compilation to. */
Reporter reporter();
/**
* Returns incremental compiler options.
*
* @see sbt.inc.IncOptions for details
*
* You can get default options by calling <code>sbt.inc.IncOptions.toStringMap(sbt.inc.IncOptions.Default)</code>.
*
* In the future, we'll extend API in <code>xsbti</code> to provide factory methods that would allow to obtain
* defaults values so one can depend on <code>xsbti</code> package only.
**/
Map<String, String> incrementalCompilerOptions();
}

View File

@ -1,12 +0,0 @@
package xsbti.compile;
import java.io.File;
public interface SingleOutput extends Output {
/** The directory where class files should be generated.
* Incremental compilation will manage the class files in this directory.
* In particular, outdated class files will be deleted before compilation.
* It is important that this directory is exclusively used for one set of sources. */
File outputDirectory();
}

View File

@ -5,6 +5,7 @@ package sbt
import xsbti.{ Logger => xLogger, F0 }
import xsbti.{ Maybe, Position, Problem, Severity }
import sys.process.ProcessLogger
import java.io.File
@ -117,6 +118,10 @@ trait Logger extends xLogger {
final def info(message: => String): Unit = log(Level.Info, message)
final def warn(message: => String): Unit = log(Level.Warn, message)
final def error(message: => String): Unit = log(Level.Error, message)
// Added by sys.process.ProcessLogger
final def err(message: => String): Unit = log(Level.Error, message)
// sys.process.ProcessLogger
final def out(message: => String): Unit = log(Level.Info, message)
def ansiCodesSupported: Boolean = false