aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/printing/Formatting.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-10-04 15:51:15 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-10 13:25:37 +0200
commite754a2d790e0cf5ab2c1480166a42cbb908add0f (patch)
tree7ca2847e39d1b487b060a188933ff1678a0ae806 /src/dotty/tools/dotc/printing/Formatting.scala
parentd2b620541b18bb50d2a2b89194e1778c64bba567 (diff)
downloaddotty-e754a2d790e0cf5ab2c1480166a42cbb908add0f.tar.gz
dotty-e754a2d790e0cf5ab2c1480166a42cbb908add0f.tar.bz2
dotty-e754a2d790e0cf5ab2c1480166a42cbb908add0f.zip
Change `typeDiff` to highlight changes less than 50%
Diffstat (limited to 'src/dotty/tools/dotc/printing/Formatting.scala')
-rw-r--r--src/dotty/tools/dotc/printing/Formatting.scala12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/printing/Formatting.scala b/src/dotty/tools/dotc/printing/Formatting.scala
index 76d2bdc18..719c23e84 100644
--- a/src/dotty/tools/dotc/printing/Formatting.scala
+++ b/src/dotty/tools/dotc/printing/Formatting.scala
@@ -242,17 +242,17 @@ object Formatting {
* correct `Context` for printing should also be passed when calling the
* method.
*
- * @return the (found, expected) with coloring to highlight the difference
+ * @return the (found, expected, changePercentage) with coloring to
+ * highlight the difference
*/
def typeDiff(found: Type, expected: Type)(implicit ctx: Context): (String, String) = {
val fnd = wrapNonSensical(found, found.show)
val exp = wrapNonSensical(expected, expected.show)
- (found, expected) match {
- case (_: RefinedType, _: RefinedType) if ctx.settings.color.value != "never" =>
- DiffUtil.mkColoredTypeDiff(fnd, exp)
- case _ =>
- (hl"$fnd", hl"$exp")
+ DiffUtil.mkColoredTypeDiff(fnd, exp) match {
+ case _ if ctx.settings.color.value == "never" => (fnd, exp)
+ case (fnd, exp, change) if change < 0.5 => (fnd, exp)
+ case _ => (fnd, exp)
}
}
}