Skip to content

Commit

Permalink
Add helper methods to IC for reading analysis cache files
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlugter authored and harrah committed May 7, 2012
1 parent 80500b5 commit fdf9be1
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions compile/integration/IncrementalCompiler.scala
@@ -1,5 +1,6 @@
package sbt.compiler

import sbt.CompileSetup
import sbt.inc.Analysis
import xsbti.{Logger, Maybe}
import xsbti.compile._
Expand Down Expand Up @@ -29,4 +30,17 @@ object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler]
val raw = new RawCompiler(instance, sbt.ClasspathOptions.auto, log)
AnalyzingCompiler.compileSources(sourceJar :: Nil, targetJar, interfaceJar :: Nil, label, raw, log)
}

def readCache(file: File): Option[(Analysis, CompileSetup)] =
try { Some(readCacheUncaught(file)) } catch { case _: Exception => None }

def readAnalysis(file: File): Analysis =
try { readCacheUncaught(file)._1 } catch { case _: Exception => Analysis.Empty }

def readCacheUncaught(file: File): (Analysis, CompileSetup) =
{
import sbinary.DefaultProtocol.{immutableMapFormat, immutableSetFormat, StringFormat, tuple2Format}
import sbt.inc.AnalysisFormats._
sbt.IO.gzipFileIn(file)( in => sbinary.Operations.read[(Analysis, CompileSetup)](in) )
}
}

0 comments on commit fdf9be1

Please sign in to comment.