Skip to content

Commit 396713b

Browse files
committed
Reorganise code in IncrementalCommon and document it
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.
1 parent a813eb9 commit 396713b

4 files changed

Lines changed: 625 additions & 403 deletions

File tree

internal/zinc-core/src/main/scala/sbt/internal/inc/Incremental.scala

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object Incremental {
6363
val previous = previous0 match { case a: Analysis => a }
6464
val incremental: IncrementalCommon =
6565
new IncrementalNameHashing(log, options)
66-
val initialChanges = incremental.changedInitial(sources, previous, current, lookup)
66+
val initialChanges = incremental.detectInitialChanges(sources, previous, current, lookup)
6767
val binaryChanges = new DependencyChanges {
6868
val modifiedBinaries = initialChanges.binaryDeps.toArray
6969
val modifiedClasses = initialChanges.external.allModified.toArray
@@ -118,15 +118,11 @@ object Incremental {
118118
private[inc] def apiDebug(options: IncOptions): Boolean =
119119
options.apiDebug || java.lang.Boolean.getBoolean(apiDebugProp)
120120

121-
private[sbt] def prune(invalidatedSrcs: Set[File], previous: CompileAnalysis): Analysis =
122-
prune(invalidatedSrcs, previous, ClassFileManager.deleteImmediately)
123-
124-
private[sbt] def prune(invalidatedSrcs: Set[File],
125-
previous0: CompileAnalysis,
126-
classfileManager: XClassFileManager): Analysis = {
127-
val previous = previous0 match { case a: Analysis => a }
128-
classfileManager.delete(invalidatedSrcs.flatMap(previous.relations.products).toArray)
129-
previous -- invalidatedSrcs
121+
private[sbt] def prune(invalidatedSrcs: Set[File], previous0: CompileAnalysis): Analysis = {
122+
val previous = previous0.asInstanceOf[Analysis]
123+
IncrementalCommon.pruneClassFilesOfInvalidations(invalidatedSrcs,
124+
previous,
125+
ClassFileManager.deleteImmediately)
130126
}
131127

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

0 commit comments

Comments
 (0)