Skip to content

Commit

Permalink
invalidate by external improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszwawrzyk committed Aug 17, 2018
1 parent 4306042 commit 7d72fa6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private final class IncrementalNameHashing(log: sbt.util.Logger, options: IncOpt
externalAPIChange: APIChange,
isScalaClass: String => Boolean): Set[String] = {
val modifiedBinaryClassName = externalAPIChange.modifiedClass
val invalidationReason = memberRefInvalidator.invalidationReason(externalAPIChange)
val invalidationReason = memberRefInvalidator.invalidationReason(externalAPIChange).capitalize
log.debug(
s"$invalidationReason\nAll member reference dependencies will be considered within this context.")
// Propagate inheritance dependencies transitively.
Expand Down Expand Up @@ -136,20 +136,17 @@ private final class IncrementalNameHashing(log: sbt.util.Logger, options: IncOpt
def debugMessage: String = {
if (all.isEmpty) s"Change $change does not affect any class."
else {
val byTransitiveInheritance =
if (transitiveInheritance.nonEmpty) s"by transitive inheritance: $transitiveInheritance"
else ""
val byLocalInheritance =
if (localInheritance.nonEmpty) s"by local inheritance: $localInheritance" else ""
val byMemberRef =
if (memberRef.nonEmpty) s"by member reference: $memberRef" else ""

s"""Change $change invalidates ${all.size} classes due to ${memberRefInvalidator
.invalidationReason(change)}
|\t> $byTransitiveInheritance
|\t> $byLocalInheritance
|\t> $byMemberRef
""".stripMargin
def by(reason: String, classes: Set[String]) = {
if (classes.isEmpty) ""
else {
s"\tby $reason: ${classes.mkString(", ")}\n"
}
}

s"${all.size} classes were invalidated due to ${memberRefInvalidator.invalidationReason(change)}\n" +
by("transitive inheritance", transitiveInheritance) +
by("local inheritance", localInheritance) +
by("member reference", memberRef)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,15 @@ private[inc] class MemberRefInvalidator(log: Logger, logRecompileOnMacro: Boolea

def invalidationReason(apiChange: APIChange): String = apiChange match {
case TraitPrivateMembersModified(modifiedClass) =>
s"The private signature of trait ${modifiedClass} changed."
s"the private signature of trait $modifiedClass changed."
case APIChangeDueToMacroDefinition(modifiedSrcFile) =>
s"The $modifiedSrcFile source file declares a macro."
s"the $modifiedSrcFile source file declares a macro."
case NamesChange(modifiedClass, modifiedNames) =>
modifiedNames.in(UseScope.Implicit) match {
case changedImplicits if changedImplicits.isEmpty =>
s"""|The $modifiedClass has the following regular definitions changed:
|\t${modifiedNames.names.mkString(", ")}.""".stripMargin
s"the $modifiedClass has the following regular definitions changed: ${modifiedNames.names}"
case changedImplicits =>
s"""|The $modifiedClass has the following implicit definitions changed:
|\t${changedImplicits.mkString(", ")}.""".stripMargin
s"""the $modifiedClass has the following implicit definitions changed: $changedImplicits""".stripMargin
}
}

Expand Down

0 comments on commit 7d72fa6

Please sign in to comment.