* Fixed problem where a dependency on only static members of a Java class was not recorded

* Fixed problem where new dependencies on sources not included in the compilation were not added



git-svn-id: https://simple-build-tool.googlecode.com/svn/trunk@859 d89573ee-9141-11dd-94d4-bdf5e562f29c
This commit is contained in:
dmharrah 2009-07-11 18:48:35 +00:00
parent 39573225d1
commit 6b2c36d0ef
3 changed files with 41 additions and 24 deletions

View File

@ -95,6 +95,11 @@ sealed class BasicAnalysis(analysisPath: Path, projectPath: Path, log: Logger) e
def addSourceDependency(on: Path, from: Path) = add(on, from, sourceDependencyMap)
def addExternalDependency(on: File, from: Path) = add(on.getAbsoluteFile, from, externalDependencyMap)
def addProductDependency(on: Path, from: Path) =
{
for( (source, _) <- productMap.find(_._2.contains(on)) )
addSourceDependency(source, from)
}
def addProduct(source: Path, file: Path) = add(source, file, productMap)
def addSource(source: Path) =
{

View File

@ -45,6 +45,12 @@ trait AnalysisCallback extends NotNull
/** Called to indicate that the source file <code>sourcePath</code> depends on the class file
* <code>classFile</code>.*/
def classDependency(classFile: File, sourcePath: Path): Unit
/** Called to indicate that the source file <code>sourcePath</code> depends on the class file
* <code>classFile</code> that is a product of some source. This differs from classDependency
* because it is really a sourceDependency. The source corresponding to <code>classFile</code>
* was not incuded in the compilation so the plugin doesn't know what the source is though. It
* only knows that the class file came from the output directory.*/
def productDependency(classFile: Path, sourcePath: Path): Unit
/** Called to indicate that the source file <code>sourcePath</code> produces a class file at
* <code>modulePath</code>.*/
def generatedClass(sourcePath: Path, modulePath: Path): Unit
@ -58,36 +64,30 @@ abstract class BasicAnalysisCallback[A <: BasicCompileAnalysis](val basePath: Pa
{
def superclassNotFound(superclassName: String) {}
def beginSource(sourcePath: Path)
{
def beginSource(sourcePath: Path): Unit =
analysis.addSource(sourcePath)
}
def sourceDependency(dependsOnPath: Path, sourcePath: Path)
{
def sourceDependency(dependsOnPath: Path, sourcePath: Path): Unit =
analysis.addSourceDependency(dependsOnPath, sourcePath)
}
def jarDependency(jarFile: File, sourcePath: Path)
{
def jarDependency(jarFile: File, sourcePath: Path): Unit =
analysis.addExternalDependency(jarFile, sourcePath)
}
def classDependency(classFile: File, sourcePath: Path)
{
def classDependency(classFile: File, sourcePath: Path): Unit =
analysis.addExternalDependency(classFile, sourcePath)
}
def generatedClass(sourcePath: Path, modulePath: Path)
{
def productDependency(classFile: Path, sourcePath: Path): Unit =
analysis.addProductDependency(classFile, sourcePath)
def generatedClass(sourcePath: Path, modulePath: Path): Unit =
analysis.addProduct(sourcePath, modulePath)
}
def endSource(sourcePath: Path)
{
def endSource(sourcePath: Path): Unit =
analysis.removeSelfDependency(sourcePath)
}
}
abstract class BasicCompileAnalysisCallback(basePath: Path, superclassNames: Iterable[String], analysis: CompileAnalysis)
extends BasicAnalysisCallback(basePath, superclassNames, analysis)
{
def foundApplication(sourcePath: Path, className: String)
{
def foundApplication(sourcePath: Path, className: String): Unit =
analysis.addApplication(sourcePath, className)
}
}

View File

@ -119,9 +119,13 @@ class Analyzer(val global: Global) extends Plugin
case ze: ZipArchive#Entry => callback.jarDependency(new File(ze.getArchive.getName), sourcePath)
case pf: PlainFile =>
{
// ignore dependencies in the output directory: these are handled by source dependencies
if(Path.relativize(outputPath, pf.file).isEmpty)
callback.classDependency(pf.file, sourcePath)
Path.relativize(outputPath, pf.file) match
{
case None => // dependency is a class file outside of the output directory
callback.classDependency(pf.file, sourcePath)
case Some(relativeToOutput) => // dependency is a product of a source not included in this compilation
callback.productDependency(relativeToOutput, sourcePath)
}
}
case _ => ()
}
@ -182,6 +186,14 @@ class Analyzer(val global: Global) extends Plugin
val entry = classPath.root.find(name, false)
if (entry ne null)
Some(entry.classFile)
else if(isTopLevelModule(sym))
{
val linked = sym.linkedClassOfModule
if(linked == NoSymbol)
None
else
classFile(linked)
}
else
None
}