From 7d72fa6a2a1c46c8a0c6acd58bb61ec6ebf72928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wawrzyk?= Date: Fri, 17 Aug 2018 09:34:50 +0200 Subject: [PATCH] invalidate by external improvements --- .../internal/inc/IncrementalNameHashing.scala | 27 +++++++++---------- .../internal/inc/MemberRefInvalidator.scala | 10 +++---- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala index 4d2b621c91..a88c921714 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/IncrementalNameHashing.scala @@ -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. @@ -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) } } diff --git a/internal/zinc-core/src/main/scala/sbt/internal/inc/MemberRefInvalidator.scala b/internal/zinc-core/src/main/scala/sbt/internal/inc/MemberRefInvalidator.scala index 172777f4de..affd019ac8 100644 --- a/internal/zinc-core/src/main/scala/sbt/internal/inc/MemberRefInvalidator.scala +++ b/internal/zinc-core/src/main/scala/sbt/internal/inc/MemberRefInvalidator.scala @@ -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 } }