@@ -45,7 +45,7 @@ internal class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2
45
45
* @param orig The original sequence.
46
46
* @param rev The revised sequence.
47
47
* @return A minimum [PathNode] across the differences graph.
48
- * @throws DifferentiationFailedException if a diff path could not be found.
48
+ * @throws IllegalStateException if a diff path could not be found.
49
49
*/
50
50
private fun buildPath (orig : List <T >, rev : List <T >, progress : DiffAlgorithmListener ? ): PathNode ? {
51
51
// these are local constants
@@ -74,13 +74,13 @@ internal class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2
74
74
}
75
75
diagonal[kminus] = null // no longer used
76
76
var j = i - k
77
- var node = PathNode (i, j, false , false , prev)
77
+ var node = PathNode (i, j, snake = false , bootstrap = false , prev = prev)
78
78
while (i < N && j < M && equalizer.invoke(orig[i], rev[j])) {
79
79
i++
80
80
j++
81
81
}
82
82
if (i != node.i) {
83
- node = PathNode (i, j, true , false , node)
83
+ node = PathNode (i, j, snake = true , bootstrap = false , prev = node)
84
84
}
85
85
diagonal[kmiddle] = node
86
86
if (i >= N && j >= M ) {
@@ -94,14 +94,13 @@ internal class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2
94
94
}
95
95
96
96
/* *
97
- * Constructs a [Patch] from a difference path.
97
+ * Constructs a patch from a difference path.
98
98
*
99
99
* @param actualPath The path.
100
100
* @param orig The original sequence.
101
101
* @param rev The revised sequence.
102
- * @return A [Patch] script corresponding to the path.
103
- * @throws DifferentiationFailedException if a [Patch] could not be built from the given
104
- * path.
102
+ * @return A list of [Change]s corresponding to the path.
103
+ * @throws IllegalStateException if a patch could not be built from the given path.
105
104
*/
106
105
private fun buildRevision (actualPath : PathNode ? , orig : List <T >, rev : List <T >): List <Change > {
107
106
var path: PathNode ? = actualPath
@@ -114,14 +113,14 @@ internal class MyersDiff<T>(private val equalizer: (T, T) -> Boolean = { t1, t2
114
113
val i: Int = path.i
115
114
val j: Int = path.j
116
115
path = path.prev
117
- val ianchor : Int = path!! .i
118
- val janchor : Int = path.j
119
- if (ianchor == i && janchor != j) {
120
- changes.add(Change (DeltaType .INSERT , ianchor , i, janchor , j))
121
- } else if (ianchor != i && janchor == j) {
122
- changes.add(Change (DeltaType .DELETE , ianchor , i, janchor , j))
116
+ val iAnchor : Int = path!! .i
117
+ val jAnchor : Int = path.j
118
+ if (iAnchor == i && jAnchor != j) {
119
+ changes.add(Change (DeltaType .INSERT , iAnchor , i, jAnchor , j))
120
+ } else if (iAnchor != i && jAnchor == j) {
121
+ changes.add(Change (DeltaType .DELETE , iAnchor , i, jAnchor , j))
123
122
} else {
124
- changes.add(Change (DeltaType .CHANGE , ianchor , i, janchor , j))
123
+ changes.add(Change (DeltaType .CHANGE , iAnchor , i, jAnchor , j))
125
124
}
126
125
if (path.snake) {
127
126
path = path.prev
0 commit comments