From 83a131e4f5c73e1b20899d5deb8ef7e4c0fb1517 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Thu, 5 Dec 2013 07:24:17 +0100 Subject: [PATCH] Introduce `IncrementalCommon.invalidateSource` method. In addition to `invalidateSources` we introduce `invalidateSource` that invalidates dependencies of a single source. This is needed for the name hashing algorithm because its invalidation logic depends on information about API changes of each source file individually. The refactoring is done in `IncrementalCommon` class so it affects the default implementation as well. However, this refactoring does not affect the result of invalidation in the default implementation. --- compile/inc/src/main/scala/sbt/inc/Incremental.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compile/inc/src/main/scala/sbt/inc/Incremental.scala b/compile/inc/src/main/scala/sbt/inc/Incremental.scala index fe4f03861..d4c6d7871 100644 --- a/compile/inc/src/main/scala/sbt/inc/Incremental.scala +++ b/compile/inc/src/main/scala/sbt/inc/Incremental.scala @@ -316,13 +316,20 @@ private abstract class IncrementalCommon(log: Logger, options: IncOptions) { private[this] def invalidateSources(directDeps: File => Set[File], publicInherited: File => Set[File], changes: APIChanges[File]): Set[File] = { val initial = changes.allModified.toSet + val all = (changes.apiChanges flatMap { change => + invalidateSource(directDeps, publicInherited, change) + }).toSet + includeInitialCond(initial, all, f => directDeps(f) ++ publicInherited(f)) + } + + private[this] def invalidateSource(directDeps: File => Set[File], publicInherited: File => Set[File], change: APIChange[File]): Set[File] = { log.debug("Invalidating by inheritance (transitively)...") - val transitiveInherited = transitiveDeps(initial)(publicInherited) + val transitiveInherited = transitiveDeps(Set(change.modified))(publicInherited) log.debug("Invalidated by transitive public inheritance: " + transitiveInherited) val direct = transitiveInherited flatMap directDeps log.debug("Invalidated by direct dependency: " + direct) val all = transitiveInherited ++ direct - includeInitialCond(initial, all, f => directDeps(f) ++ publicInherited(f)) + all } /** Conditionally include initial sources that are dependencies of newly invalidated sources.