mirror of https://github.com/sbt/sbt.git
Remove AnalysisCallback.{beginSource, endSource} methods.
As pointed out by @harrah in #705, both beginSource and endSource are not used in sbt internally for anything meaningful. We've discussed an option of deprecating those methods but since they are not doing anything meaningful Mark prefers to have compile-time error in case somebody implements or calls those methods. I agree with that hence removal.
This commit is contained in:
parent
57306e6257
commit
fea18a4fbe
|
|
@ -151,9 +151,6 @@ private final class AnalysisCallback(internalMap: File => Option[File], external
|
|||
apis(sourceFile) = (HashAPI(source), savedSource)
|
||||
}
|
||||
|
||||
def endSource(sourcePath: File): Unit =
|
||||
assert(apis.contains(sourcePath))
|
||||
|
||||
def get: Analysis = addCompilation( addExternals( addBinaries( addProducts( addSources(Analysis.Empty) ) ) ) )
|
||||
def addProducts(base: Analysis): Analysis = addAll(base, classes) { case (a, src, (prod, name)) => a.addProduct(src, prod, current product prod, name ) }
|
||||
def addBinaries(base: Analysis): Analysis = addAll(base, binaryDeps)( (a, src, bin) => a.addBinaryDep(src, bin, binaryClassName(bin), current binary bin) )
|
||||
|
|
@ -178,6 +175,4 @@ private final class AnalysisCallback(internalMap: File => Option[File], external
|
|||
(outer /: bs) { (inner, b) =>
|
||||
f(inner, a, b)
|
||||
} }
|
||||
|
||||
def beginSource(source: File) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile
|
|||
{
|
||||
// build dependencies structure
|
||||
val sourceFile = unit.source.file.file
|
||||
callback.beginSource(sourceFile)
|
||||
for(on <- unit.depends) processDependency(on, inherited=false)
|
||||
for(on <- inheritedDependencies.getOrElse(sourceFile, Nil: Iterable[Symbol])) processDependency(on, inherited=true)
|
||||
def processDependency(on: Symbol, inherited: Boolean)
|
||||
|
|
@ -75,7 +74,6 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile
|
|||
else
|
||||
addGenerated(false)
|
||||
}
|
||||
callback.endSource(sourceFile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import java.io.File;
|
|||
|
||||
public interface AnalysisCallback
|
||||
{
|
||||
/** Called before the source at the given location is processed. */
|
||||
public void beginSource(File source);
|
||||
/** 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
|
||||
|
|
@ -24,8 +22,6 @@ public interface AnalysisCallback
|
|||
/** Called to indicate that the source file <code>source</code> produces a class file at
|
||||
* <code>module</code> contain class <code>name</code>.*/
|
||||
public void generatedClass(File source, File module, String name);
|
||||
/** Called after the source at the given location has been processed. */
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -5,20 +5,15 @@ package xsbti
|
|||
|
||||
class TestCallback extends AnalysisCallback
|
||||
{
|
||||
val beganSources = new ArrayBuffer[File]
|
||||
val endedSources = new ArrayBuffer[File]
|
||||
val sourceDependencies = new ArrayBuffer[(File, File, Boolean)]
|
||||
val binaryDependencies = new ArrayBuffer[(File, String, File, Boolean)]
|
||||
val products = new ArrayBuffer[(File, File, String)]
|
||||
val apis = new ArrayBuffer[(File, xsbti.api.SourceAPI)]
|
||||
|
||||
def beginSource(source: File) { beganSources += source }
|
||||
|
||||
def sourceDependency(dependsOn: File, source: File, inherited: Boolean) { sourceDependencies += ((dependsOn, source, inherited)) }
|
||||
def binaryDependency(binary: File, name: String, source: File, inherited: Boolean) { binaryDependencies += ((binary, name, source, inherited)) }
|
||||
def generatedClass(source: File, module: File, name: String) { products += ((source, module, name)) }
|
||||
def endSource(source: File) { endedSources += source }
|
||||
|
||||
def api(source: File, sourceAPI: xsbti.api.SourceAPI) { apis += ((source, sourceAPI)) }
|
||||
def problem(category: String, pos: xsbti.Position, message: String, severity: xsbti.Severity, reported: Boolean) {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,12 +33,11 @@ private[sbt] object Analyze
|
|||
sourceFile <- classFile.sourceFile orElse guessSourceName(newClass.getName);
|
||||
source <- guessSourcePath(sourceMap, classFile, log))
|
||||
{
|
||||
analysis.beginSource(source)
|
||||
analysis.generatedClass(source, newClass, classFile.className)
|
||||
productToSource(newClass) = source
|
||||
sourceToClassFiles.getOrElseUpdate(source, new ArrayBuffer[ClassFile]) += classFile
|
||||
}
|
||||
|
||||
|
||||
// get class to class dependencies and map back to source to class dependencies
|
||||
for( (source, classFiles) <- sourceToClassFiles )
|
||||
{
|
||||
|
|
@ -65,17 +64,14 @@ private[sbt] object Analyze
|
|||
}
|
||||
}
|
||||
def processDependencies(tpes: Iterable[String], inherited: Boolean): Unit = tpes.foreach(tpe => processDependency(tpe, inherited))
|
||||
|
||||
|
||||
val notInherited = classFiles.flatMap(_.types).toSet -- publicInherited
|
||||
processDependencies(notInherited, false)
|
||||
processDependencies(publicInherited, true)
|
||||
analysis.endSource(source)
|
||||
}
|
||||
|
||||
for( source <- sources filterNot sourceToClassFiles.keySet ) {
|
||||
analysis.beginSource(source)
|
||||
analysis.api(source, new xsbti.api.SourceAPI(Array(), Array()))
|
||||
analysis.endSource(source)
|
||||
}
|
||||
}
|
||||
private[this] def urlAsFile(url: URL, log: Logger): Option[File] =
|
||||
|
|
@ -114,7 +110,7 @@ private[sbt] object Analyze
|
|||
}
|
||||
private def findSource(sourceNameMap: Map[String, Iterable[File]], pkg: List[String], sourceFileName: String): List[File] =
|
||||
refine( (sourceNameMap get sourceFileName).toList.flatten.map { x => (x,x.getParentFile) }, pkg.reverse)
|
||||
|
||||
|
||||
@tailrec private def refine(sources: List[(File, File)], pkgRev: List[String]): List[File] =
|
||||
{
|
||||
def make = sources.map(_._1)
|
||||
|
|
@ -155,7 +151,7 @@ private[sbt] object Analyze
|
|||
method.getReturnType == unit &&
|
||||
method.getParameterTypes.toList == strArray
|
||||
private def isMain(modifiers: Int): Boolean = (modifiers & mainModifiers) == mainModifiers && (modifiers & notMainModifiers) == 0
|
||||
|
||||
|
||||
private val mainModifiers = STATIC | PUBLIC
|
||||
private val notMainModifiers = ABSTRACT
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue