@@ -25,7 +25,6 @@ package io.github.petertrr.diffutils
25
25
import io.github.petertrr.diffutils.algorithm.DiffAlgorithm
26
26
import io.github.petertrr.diffutils.algorithm.DiffAlgorithmListener
27
27
import io.github.petertrr.diffutils.algorithm.myers.MyersDiff
28
- import io.github.petertrr.diffutils.patch.Chunk
29
28
import io.github.petertrr.diffutils.patch.Patch
30
29
import io.github.petertrr.diffutils.patch.PatchFailedException
31
30
@@ -39,22 +38,22 @@ import io.github.petertrr.diffutils.patch.PatchFailedException
39
38
* @param progress progress listener
40
39
* @return The patch describing the difference between the original and revised sequences.
41
40
*/
42
- fun <T > diff (original : List <T >, revised : List <T >, progress : DiffAlgorithmListener ? ): Patch <T > {
41
+ public fun <T > diff (original : List <T >, revised : List <T >, progress : DiffAlgorithmListener ? ): Patch <T > {
43
42
return diff(original, revised, MyersDiff <T >(), progress)
44
43
}
45
44
46
- fun <T > diff (original : List <T >, revised : List <T >): Patch <T > {
45
+ public fun <T > diff (original : List <T >, revised : List <T >): Patch <T > {
47
46
return diff(original, revised, MyersDiff (), null )
48
47
}
49
48
50
- fun <T > diff (original : List <T >, revised : List <T >, includeEqualParts : Boolean ): Patch <T > {
49
+ public fun <T > diff (original : List <T >, revised : List <T >, includeEqualParts : Boolean ): Patch <T > {
51
50
return diff(original, revised, MyersDiff (), null , includeEqualParts)
52
51
}
53
52
54
53
/* *
55
54
* Computes the difference between the original and revised text.
56
55
*/
57
- fun diff (sourceText : String , targetText : String ,
56
+ public fun diff (sourceText : String , targetText : String ,
58
57
progress : DiffAlgorithmListener ? ): Patch <String > {
59
58
return diff(sourceText.split(" \n " ),
60
59
targetText.split(" \n " ),
@@ -73,7 +72,7 @@ fun diff(sourceText: String, targetText: String,
73
72
* (Object.equals). If `null` the default equalizer of the default algorithm is used..
74
73
* @return The patch describing the difference between the original and revised sequences.
75
74
*/
76
- fun <T > diff (
75
+ public fun <T > diff (
77
76
source : List <T >, target : List <T >,
78
77
equalizer : ((T , T ) -> Boolean )?
79
78
): Patch <T > {
@@ -85,7 +84,7 @@ fun <T> diff(
85
84
} else diff(source, target, MyersDiff ())
86
85
}
87
86
88
- fun <T > diff (
87
+ public fun <T > diff (
89
88
original : List <T >, revised : List <T >,
90
89
algorithm : DiffAlgorithm <T >, progress : DiffAlgorithmListener ?
91
90
): Patch <T > {
@@ -104,7 +103,7 @@ fun <T> diff(
104
103
* @return The patch describing the difference between the original and revised sequences. Never
105
104
* `null`.
106
105
*/
107
- fun <T > diff (
106
+ public fun <T > diff (
108
107
original : List <T >, revised : List <T >,
109
108
algorithm : DiffAlgorithm <T >, progress : DiffAlgorithmListener ? ,
110
109
includeEqualParts : Boolean
@@ -122,7 +121,7 @@ fun <T> diff(
122
121
* @return The patch describing the difference between the original and revised sequences. Never
123
122
* `null`.
124
123
*/
125
- fun <T > diff (original : List <T >, revised : List <T >, algorithm : DiffAlgorithm <T >): Patch <T > {
124
+ public fun <T > diff (original : List <T >, revised : List <T >, algorithm : DiffAlgorithm <T >): Patch <T > {
126
125
return diff(original, revised, algorithm, null )
127
126
}
128
127
@@ -135,7 +134,7 @@ fun <T> diff(original: List<T>, revised: List<T>, algorithm: DiffAlgorithm<T>):
135
134
* @param revised
136
135
* @return
137
136
*/
138
- fun diffInline (original : String , revised : String ): Patch <String > {
137
+ public fun diffInline (original : String , revised : String ): Patch <String > {
139
138
val origList: MutableList <String > = arrayListOf ()
140
139
val revList: MutableList <String > = arrayListOf ()
141
140
for (character in original.toCharArray()) {
@@ -145,13 +144,13 @@ fun diffInline(original: String, revised: String): Patch<String> {
145
144
revList.add(character.toString())
146
145
}
147
146
val patch: Patch <String > = diff(origList, revList)
148
- patch.getDeltas() .map { delta ->
147
+ patch.deltas .map { delta ->
149
148
delta.withChunks(
150
149
delta.source.copy(lines = compressLines(delta.source.lines, " " )),
151
150
delta.target.copy(lines = compressLines(delta.target.lines, " " ))
152
151
)
153
152
}
154
- .let { patch.setDeltas(it ) }
153
+ .let { patch.deltas = it.toMutableList( ) }
155
154
return patch
156
155
}
157
156
@@ -170,7 +169,7 @@ private fun compressLines(lines: List<String>, delimiter: String): List<String>
170
169
* @throws PatchFailedException if can't apply patch
171
170
*/
172
171
@kotlin.Throws (PatchFailedException ::class )
173
- fun <T > patch (original : List <T >, patch : Patch <T >): List <T > {
172
+ public fun <T > patch (original : List <T >, patch : Patch <T >): List <T > {
174
173
return patch.applyTo(original)
175
174
}
176
175
@@ -181,6 +180,7 @@ fun <T> patch(original: List<T>, patch: Patch<T>): List<T> {
181
180
* @param patch the given patch
182
181
* @return the original text
183
182
*/
184
- fun <T > unpatch (revised : List <T >, patch : Patch <T >): List <T > {
183
+ @Suppress(" UNUSED" )
184
+ public fun <T > unpatch (revised : List <T >, patch : Patch <T >): List <T > {
185
185
return patch.restore(revised)
186
186
}
0 commit comments