<commit_before>package sbt.compiler

	import sbt.inc.Analysis
	import xsbti.{Logger, Maybe}
	import xsbti.compile._

	import java.io.File

object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler]
{
	def compile(in: Inputs[Analysis, AnalyzingCompiler], log: Logger): Analysis =
	{
		val setup = in.setup; import setup._
		val options = in.options; import options.{options => scalacOptions, _}
		val compilers = in.compilers; import compilers._
		val agg = new AggressiveCompile(setup.cacheFile)
		val aMap = (f: File) => m2o(analysisMap(f))
		val defClass = (f: File) => { val dc = definesClass(f); (name: String) => dc.apply(name) }
		agg(scalac, javac, sources, classpath, classesDirectory, cache, scalacOptions, javacOptions, aMap, defClass, maxErrors, order, skip)(log)
	}

	private[this] def m2o[S](opt: Maybe[S]): Option[S] = if(opt.isEmpty) None else Some(opt.get)

	def newScalaCompiler(instance: ScalaInstance, interfaceJar: File, options: ClasspathOptions, log: Logger): AnalyzingCompiler =
		new AnalyzingCompiler(instance, CompilerInterfaceProvider.constant(interfaceJar), options, log)

	def compileInterfaceJar(label: String, sourceJar: File, targetJar: File, interfaceJar: File, instance: ScalaInstance, log: Logger)
	{
		val raw = new RawCompiler(instance, sbt.ClasspathOptions.auto, log)
		AnalyzingCompiler.compileSources(sourceJar :: Nil, targetJar, interfaceJar :: Nil, label, raw, log)
	}
}<commit_msg>Add helper methods to IC for reading analysis cache files<commit_after>package sbt.compiler

	import sbt.CompileSetup
	import sbt.inc.Analysis
	import xsbti.{Logger, Maybe}
	import xsbti.compile._

	import java.io.File

object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler]
{
	def compile(in: Inputs[Analysis, AnalyzingCompiler], log: Logger): Analysis =
	{
		val setup = in.setup; import setup._
		val options = in.options; import options.{options => scalacOptions, _}
		val compilers = in.compilers; import compilers._
		val agg = new AggressiveCompile(setup.cacheFile)
		val aMap = (f: File) => m2o(analysisMap(f))
		val defClass = (f: File) => { val dc = definesClass(f); (name: String) => dc.apply(name) }
		agg(scalac, javac, sources, classpath, classesDirectory, cache, scalacOptions, javacOptions, aMap, defClass, maxErrors, order, skip)(log)
	}

	private[this] def m2o[S](opt: Maybe[S]): Option[S] = if(opt.isEmpty) None else Some(opt.get)

	def newScalaCompiler(instance: ScalaInstance, interfaceJar: File, options: ClasspathOptions, log: Logger): AnalyzingCompiler =
		new AnalyzingCompiler(instance, CompilerInterfaceProvider.constant(interfaceJar), options, log)

	def compileInterfaceJar(label: String, sourceJar: File, targetJar: File, interfaceJar: File, instance: ScalaInstance, log: Logger)
	{
		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) )
	}
}
{'fraction_non_alphanumeric': 0.11874105865522175, 'fraction_numerical': 0.0017167381974248926, 'mean_word_length': 5.814814814814815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3861197', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1105, 'n_words': 292}