Skip to content

Commit adbba2e

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 0b8923e commit adbba2e

File tree

5 files changed

+626
-405
lines changed

5 files changed

+626
-405
lines changed

internal/compiler-bridge/src/main/scala/xsbt/ExtractAPI.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ class ExtractAPI[GlobalType <: Global](
431431
def mkVar = Some(fieldDef(in, sym, keepConst = false, xsbti.api.Var.of(_, _, _, _, _)))
432432
def mkVal = Some(fieldDef(in, sym, keepConst = true, xsbti.api.Val.of(_, _, _, _, _)))
433433
if (isClass(sym))
434-
if (ignoreClass(sym)) {allNonLocalClassSymbols.+=(sym); None}
435-
else Some(classLike(in, sym))
434+
if (ignoreClass(sym)) { allNonLocalClassSymbols.+=(sym); None } else Some(classLike(in, sym))
436435
else if (sym.isNonClassType)
437436
Some(typeDef(in, sym))
438437
else if (sym.isVariable)

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)