Skip to content

Commit

Permalink
Reorganise code in IncrementalCommon and document it
Browse files Browse the repository at this point in the history
While I was trying to implement some improvements here, I realize that
the current code can hardly be read and reused. I struggled as well to
understand the nitty-gritty of the algorithm as the control flow was not
clear and the order of functions was confusing.

This commit aims to fix this by reorganising the code to allow for more
reuse (functions in `IncrementalCommon`'s companion), reorganizes the
outline of `IncrementalCommon` to have clearer names and structure and
documents the most important parts of the code with implementation and
contract details.
  • Loading branch information
jvican committed Aug 26, 2018
1 parent a813eb9 commit 396713b
Show file tree
Hide file tree
Showing 4 changed files with 625 additions and 403 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object Incremental {
val previous = previous0 match { case a: Analysis => a }
val incremental: IncrementalCommon =
new IncrementalNameHashing(log, options)
val initialChanges = incremental.changedInitial(sources, previous, current, lookup)
val initialChanges = incremental.detectInitialChanges(sources, previous, current, lookup)
val binaryChanges = new DependencyChanges {
val modifiedBinaries = initialChanges.binaryDeps.toArray
val modifiedClasses = initialChanges.external.allModified.toArray
Expand Down Expand Up @@ -118,15 +118,11 @@ object Incremental {
private[inc] def apiDebug(options: IncOptions): Boolean =
options.apiDebug || java.lang.Boolean.getBoolean(apiDebugProp)

private[sbt] def prune(invalidatedSrcs: Set[File], previous: CompileAnalysis): Analysis =
prune(invalidatedSrcs, previous, ClassFileManager.deleteImmediately)

private[sbt] def prune(invalidatedSrcs: Set[File],
previous0: CompileAnalysis,
classfileManager: XClassFileManager): Analysis = {
val previous = previous0 match { case a: Analysis => a }
classfileManager.delete(invalidatedSrcs.flatMap(previous.relations.products).toArray)
previous -- invalidatedSrcs
private[sbt] def prune(invalidatedSrcs: Set[File], previous0: CompileAnalysis): Analysis = {
val previous = previous0.asInstanceOf[Analysis]
IncrementalCommon.pruneClassFilesOfInvalidations(invalidatedSrcs,
previous,
ClassFileManager.deleteImmediately)
}

private[this] def manageClassfiles[T](options: IncOptions)(run: XClassFileManager => T): T = {
Expand Down
Loading

0 comments on commit 396713b

Please sign in to comment.