From e988b0e51e6be61d818a80c2fdc4ce3d524283ab Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sun, 22 Nov 2009 22:57:08 -0500 Subject: [PATCH] Transient access to API structure from xsbt compiler interface --- project/build.properties | 4 ++-- src/main/scala/sbt/Analysis.scala | 7 +++++-- src/main/scala/sbt/AnalysisCallback.scala | 4 ++++ src/main/scala/sbt/Compile.scala | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/project/build.properties b/project/build.properties index 849b509fb..da1b182f1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1,7 +1,7 @@ #Project properties -#Mon Nov 09 21:08:39 EST 2009 +#Thu Nov 19 22:26:26 EST 2009 project.organization=org.scala-tools.sbt project.name=Simple Build Tool sbt.version=0.5.6 -project.version=0.6.3 +project.version=0.6.4-p1 scala.version=2.7.5 diff --git a/src/main/scala/sbt/Analysis.scala b/src/main/scala/sbt/Analysis.scala index 45fbee1e7..1de5a403b 100644 --- a/src/main/scala/sbt/Analysis.scala +++ b/src/main/scala/sbt/Analysis.scala @@ -164,14 +164,17 @@ import Format._ // get implicits for data types class BasicCompileAnalysis protected (analysisPath: Path, projectPath: Path, log: Logger) extends BasicAnalysis(analysisPath, projectPath, log) { /*private */val hashesMap = new HashMap[Path, Array[Byte]] + val apiMap = new HashMap[Path, xsbti.api.Source] - override protected def mapsToClear = hashesMap :: super.mapsToClear - override protected def mapsToRemoveSource = hashesMap :: super.mapsToRemoveSource + override protected def mapsToClear = apiMap :: hashesMap :: super.mapsToClear + override protected def mapsToRemoveSource = apiMap :: hashesMap :: super.mapsToRemoveSource def setHash(source: Path, hash: Array[Byte]) { hashesMap(source) = hash } def clearHash(source: Path) { hashesMap.removeKey(source) } def hash(source: Path) = hashesMap.get(source) def clearHashes() { hashesMap.clear() } + + def setAPI(source: Path, a: xsbti.api.Source) { apiMap(source) = a } def getClasses(sources: PathFinder, outputDirectory: Path): PathFinder = Path.lazyPathFinder diff --git a/src/main/scala/sbt/AnalysisCallback.scala b/src/main/scala/sbt/AnalysisCallback.scala index 51b5618c5..6ac5d606b 100644 --- a/src/main/scala/sbt/AnalysisCallback.scala +++ b/src/main/scala/sbt/AnalysisCallback.scala @@ -58,6 +58,7 @@ trait AnalysisCallback extends NotNull def endSource(sourcePath: Path): Unit /** Called when a module with a public 'main' method with the right signature is found.*/ def foundApplication(sourcePath: Path, className: String): Unit + def api(sourcePath: Path, source: xsbti.api.Source): Unit } abstract class BasicAnalysisCallback[A <: BasicCompileAnalysis](val basePath: Path, protected val analysis: A) extends AnalysisCallback { @@ -84,6 +85,9 @@ abstract class BasicAnalysisCallback[A <: BasicCompileAnalysis](val basePath: Pa def endSource(sourcePath: Path): Unit = analysis.removeSelfDependency(sourcePath) + + def api(sourcePath: Path, source: xsbti.api.Source): Unit = + analysis.setAPI(sourcePath, source) } abstract class BasicCompileAnalysisCallback(basePath: Path, analysis: CompileAnalysis) extends BasicAnalysisCallback(basePath, analysis) diff --git a/src/main/scala/sbt/Compile.scala b/src/main/scala/sbt/Compile.scala index 49a04d209..f6991eaae 100644 --- a/src/main/scala/sbt/Compile.scala +++ b/src/main/scala/sbt/Compile.scala @@ -134,4 +134,5 @@ private final class AnalysisInterface(delegate: AnalysisCallback, basePath: Path def relativizeOrAbs(base: Path, file: File) = Path.relativize(base, file).getOrElse(Path.fromFile(file)) def classPath(file: File) = relativizeOrAbs(outputPath, file) def srcPath(file: File) = relativizeOrAbs(basePath, file) + def api(file: File, source: xsbti.api.Source) = delegate.api(srcPath(file), source) } \ No newline at end of file