Skip to content

Commit 0d01da8

Browse files
committed
Add documentation for DiffUtil.mkColoredLineDiff
1 parent 64e8920 commit 0d01da8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

compiler/src/dotty/tools/dotc/util/DiffUtil.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,20 @@ object DiffUtil {
5959
(fnd, exp, totalChange.toDouble / (expected.length + found.length))
6060
}
6161

62+
/**
63+
* Return a colored diff between the tokens of every line in `expected` and `actual`. Each line of
64+
* output contains the expected value on the left and the actual value on the right.
65+
*
66+
* @param expected The expected lines
67+
* @param actual The actual lines
68+
* @return A string with one element of `expected` and `actual` on each lines, where
69+
* differences are highlighted.
70+
*/
6271
def mkColoredLineDiff(expected: Seq[String], actual: Seq[String]): String = {
63-
val expectedSize = DiffUtil.EOF.length max expected.map(_.length).max
72+
val expectedSize = EOF.length max expected.map(_.length).max
6473
actual.padTo(expected.length, "").zip(expected.padTo(actual.length, "")).map { case (act, exp) =>
6574
mkColoredLineDiff(exp, act, expectedSize)
66-
}.mkString("\n")
75+
}.mkString(System.lineSeparator)
6776
}
6877

6978
def mkColoredLineDiff(expected: String, actual: String, expectedSize: Int): String = {

0 commit comments

Comments
 (0)