Skip to content

Commit

Permalink
Optimize finding output dir for source
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Nov 29, 2018
1 parent 8e3ff4d commit 20c3a04
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/compiler-bridge/src/main/scala/xsbt/Analyzer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile {

def apply(unit: CompilationUnit): Unit = {
if (!unit.isJava) {
val sourceFile = unit.source.file.file
val sourceFile = unit.source.file
lazy val outputDir = settings.outputDirs.outputDirFor(sourceFile).file
for (iclass <- unit.icode) {
val sym = iclass.symbol
lazy val outputDir = settings.outputDirs.outputDirFor(sym.sourceFile).file
def addGenerated(separatorRequired: Boolean): Unit = {
val locatedClass = {
JarUtils.outputJar match {
case Some(outputJar) => locateClassInJar(sym, outputJar, separatorRequired)
case None => locatePlainClassFile(sym, separatorRequired)
case None => locatePlainClassFile(sym, outputDir, separatorRequired)
}
}

Expand All @@ -62,7 +62,7 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile {
// Use own map of local classes computed before lambdalift to ascertain class locality
if (localToNonLocalClass.isLocal(sym).getOrElse(true)) {
// Inform callback about local classes, non-local classes have been reported in API
callback.generatedLocalClass(sourceFile, classFile)
callback.generatedLocalClass(sourceFile.file, classFile)
}
}
}
Expand All @@ -77,8 +77,7 @@ final class Analyzer(val global: CallbackGlobal) extends LocateClassFile {
}
}

private def locatePlainClassFile(sym: Symbol, separatorRequired: Boolean): Option[File] = {
val outputDir = settings.outputDirs.outputDirFor(sym.sourceFile).file
private def locatePlainClassFile(sym: Symbol, outputDir: File, separatorRequired: Boolean): Option[File] = {
val classFile = fileForClass(outputDir, sym, separatorRequired)
if (classFile.exists()) Some(classFile) else None
}
Expand Down

0 comments on commit 20c3a04

Please sign in to comment.