Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a39411

Browse files
committed
removed diff exception
1 parentae23408 commit9a39411

File tree

15 files changed

+79
-158
lines changed

15 files changed

+79
-158
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This project uses a custom versioning scheme (and not [Semantic Versioning](http
77

88
##[Unreleased]
99

10+
***API** change: removed DiffException completely
1011
* added possibility to**process diffs** to for instance show whitespace characters
1112

1213
##[4.4] – 2019-11-06

‎java-diff-utils/src/main/java/com/github/difflib/DiffUtils.java‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
importcom.github.difflib.algorithm.DiffAlgorithmI;
1919
importcom.github.difflib.algorithm.DiffAlgorithmListener;
20-
importcom.github.difflib.algorithm.DiffException;
2120
importcom.github.difflib.algorithm.myers.MyersDiff;
2221
importcom.github.difflib.patch.AbstractDelta;
2322
importcom.github.difflib.patch.Patch;
@@ -43,21 +42,20 @@ public final class DiffUtils {
4342
* @param revised The revised text. Must not be {@code null}.
4443
* @param progress progress listener
4544
* @return The patch describing the difference between the original and revised sequences. Never {@code null}.
46-
* @throws com.github.difflib.algorithm.DiffException
4745
*/
48-
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,DiffAlgorithmListenerprogress)throwsDiffException{
46+
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,DiffAlgorithmListenerprogress) {
4947
returnDiffUtils.diff(original,revised,newMyersDiff<>(),progress);
5048
}
5149

52-
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised)throwsDiffException{
50+
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised) {
5351
returnDiffUtils.diff(original,revised,newMyersDiff<>(),null);
5452
}
5553

5654
/**
5755
* Computes the difference between the original and revised text.
5856
*/
5957
publicstaticPatch<String>diff(StringsourceText,StringtargetText,
60-
DiffAlgorithmListenerprogress)throwsDiffException{
58+
DiffAlgorithmListenerprogress) {
6159
returnDiffUtils.diff(
6260
Arrays.asList(sourceText.split("\n")),
6361
Arrays.asList(targetText.split("\n")),progress);
@@ -74,7 +72,7 @@ public static Patch<String> diff(String sourceText, String targetText,
7472
* @return The patch describing the difference between the original and revised sequences. Never {@code null}.
7573
*/
7674
publicstatic <T>Patch<T>diff(List<T>source,List<T>target,
77-
BiPredicate<T,T>equalizer)throwsDiffException{
75+
BiPredicate<T,T>equalizer) {
7876
if (equalizer !=null) {
7977
returnDiffUtils.diff(source,target,
8078
newMyersDiff<>(equalizer));
@@ -92,7 +90,7 @@ public static <T> Patch<T> diff(List<T> source, List<T> target,
9290
* @return The patch describing the difference between the original and revised sequences. Never {@code null}.
9391
*/
9492
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,
95-
DiffAlgorithmI<T>algorithm,DiffAlgorithmListenerprogress)throwsDiffException{
93+
DiffAlgorithmI<T>algorithm,DiffAlgorithmListenerprogress) {
9694
Objects.requireNonNull(original,"original must not be null");
9795
Objects.requireNonNull(revised,"revised must not be null");
9896
Objects.requireNonNull(algorithm,"algorithm must not be null");
@@ -109,7 +107,7 @@ public static <T> Patch<T> diff(List<T> original, List<T> revised,
109107
* @return The patch describing the difference between the original and revised sequences. Never {@code null}.
110108
*/
111109
publicstatic <T>Patch<T>diff(List<T>original,List<T>revised,
112-
DiffAlgorithmI<T>algorithm)throwsDiffException{
110+
DiffAlgorithmI<T>algorithm) {
113111
returndiff(original,revised,algorithm,null);
114112
}
115113

@@ -121,7 +119,7 @@ public static <T> Patch<T> diff(List<T> original, List<T> revised,
121119
* @param revised
122120
* @return
123121
*/
124-
publicstaticPatch<String>diffInline(Stringoriginal,Stringrevised)throwsDiffException{
122+
publicstaticPatch<String>diffInline(Stringoriginal,Stringrevised) {
125123
List<String>origList =newArrayList<>();
126124
List<String>revList =newArrayList<>();
127125
for (Charactercharacter :original.toCharArray()) {

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffAlgorithmI.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* Interface of a diff algorithm.
2323
*
2424
* @author Tobias Warneke (t.warneke@gmx.net)
25+
* @param <T> type of data that is diffed.
2526
*/
2627
publicinterfaceDiffAlgorithmI<T> {
2728

@@ -32,9 +33,8 @@ public interface DiffAlgorithmI<T> {
3233
* @param target target data
3334
* @param progress progress listener
3435
* @return
35-
* @throws DiffException
3636
*/
37-
List<Change>computeDiff(List<T>source,List<T>target,DiffAlgorithmListenerprogress)throwsDiffException;
37+
List<Change>computeDiff(List<T>source,List<T>target,DiffAlgorithmListenerprogress);
3838

3939
/**
4040
* Simple extension to compute a changeset using arrays.
@@ -43,9 +43,8 @@ public interface DiffAlgorithmI<T> {
4343
* @param target
4444
* @param progress
4545
* @return
46-
* @throws com.github.difflib.algorithm.DiffException
4746
*/
48-
defaultList<Change>computeDiff(T[]source,T[]target,DiffAlgorithmListenerprogress)throwsDiffException{
47+
defaultList<Change>computeDiff(T[]source,T[]target,DiffAlgorithmListenerprogress) {
4948
returncomputeDiff(Arrays.asList(source),Arrays.asList(target),progress);
5049
}
5150
}

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/DiffException.java‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/DifferentiationFailedException.java‎

Lines changed: 0 additions & 34 deletions
This file was deleted.

‎java-diff-utils/src/main/java/com/github/difflib/algorithm/myers/MyersDiff.java‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
importcom.github.difflib.algorithm.Change;
1919
importcom.github.difflib.algorithm.DiffAlgorithmI;
2020
importcom.github.difflib.algorithm.DiffAlgorithmListener;
21-
importcom.github.difflib.algorithm.DiffException;
22-
importcom.github.difflib.algorithm.DifferentiationFailedException;
2321
importcom.github.difflib.patch.DeltaType;
2422
importcom.github.difflib.patch.Patch;
2523
importjava.util.ArrayList;
@@ -50,7 +48,7 @@ public MyersDiff(final BiPredicate<T, T> equalizer) {
5048
* Return empty diff if get the error while procession the difference.
5149
*/
5250
@Override
53-
publicList<Change>computeDiff(finalList<T>source,finalList<T>target,DiffAlgorithmListenerprogress)throwsDiffException{
51+
publicList<Change>computeDiff(finalList<T>source,finalList<T>target,DiffAlgorithmListenerprogress) {
5452
Objects.requireNonNull(source,"source list must not be null");
5553
Objects.requireNonNull(target,"target list must not be null");
5654

@@ -74,8 +72,7 @@ public List<Change> computeDiff(final List<T> source, final List<T> target, Diff
7472
* @return A minimum {@link PathNode Path} accross the differences graph.
7573
* @throws DifferentiationFailedException if a diff path could not be found.
7674
*/
77-
privatePathNodebuildPath(finalList<T>orig,finalList<T>rev,DiffAlgorithmListenerprogress)
78-
throwsDifferentiationFailedException {
75+
privatePathNodebuildPath(finalList<T>orig,finalList<T>rev,DiffAlgorithmListenerprogress) {
7976
Objects.requireNonNull(orig,"original sequence is null");
8077
Objects.requireNonNull(rev,"revised sequence is null");
8178

@@ -132,7 +129,7 @@ private PathNode buildPath(final List<T> orig, final List<T> rev, DiffAlgorithmL
132129
diagonal[middle +d -1] =null;
133130
}
134131
// According to Myers, this cannot happen
135-
thrownewDifferentiationFailedException("could not find a diff path");
132+
thrownewIllegalStateException("could not find a diff path");
136133
}
137134

138135
/**

‎java-diff-utils/src/main/java/com/github/difflib/text/DiffRowGenerator.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
packagecom.github.difflib.text;
1717

1818
importcom.github.difflib.DiffUtils;
19-
importcom.github.difflib.algorithm.DiffException;
2019
importcom.github.difflib.patch.AbstractDelta;
2120
importcom.github.difflib.patch.ChangeDelta;
2221
importcom.github.difflib.patch.Chunk;
@@ -187,8 +186,7 @@ private DiffRowGenerator(Builder builder) {
187186
* @param revised the revised text
188187
* @return the DiffRows between original and revised texts
189188
*/
190-
publicList<DiffRow>generateDiffRows(List<String>original,List<String>revised)
191-
throwsDiffException {
189+
publicList<DiffRow>generateDiffRows(List<String>original,List<String>revised) {
192190
returngenerateDiffRows(original,DiffUtils.diff(original,revised,equalizer));
193191
}
194192

@@ -200,8 +198,7 @@ public List<DiffRow> generateDiffRows(List<String> original, List<String> revise
200198
* @param patch the given patch
201199
* @return the DiffRows between original and revised texts
202200
*/
203-
publicList<DiffRow>generateDiffRows(finalList<String>original,Patch<String>patch)
204-
throwsDiffException {
201+
publicList<DiffRow>generateDiffRows(finalList<String>original,Patch<String>patch) {
205202
List<DiffRow>diffRows =newArrayList<>();
206203
intendPos =0;
207204
finalList<AbstractDelta<String>>deltaList =patch.getDeltas();
@@ -291,8 +288,7 @@ List<String> normalizeLines(List<String> list) {
291288
*
292289
* @param delta the given delta
293290
*/
294-
privateList<DiffRow>generateInlineDiffs(AbstractDelta<String>delta)
295-
throwsDiffException {
291+
privateList<DiffRow>generateInlineDiffs(AbstractDelta<String>delta) {
296292
List<String>orig =normalizeLines(delta.getSource().getLines());
297293
List<String>rev =normalizeLines(delta.getTarget().getLines());
298294
List<String>origList;

‎java-diff-utils/src/test/java/com/github/difflib/DiffUtilsTest.java‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
packagecom.github.difflib;
22

3-
importcom.github.difflib.algorithm.DiffException;
43
importcom.github.difflib.patch.ChangeDelta;
54
importcom.github.difflib.patch.Chunk;
65
importcom.github.difflib.patch.DeleteDelta;
@@ -28,7 +27,7 @@
2827
publicclassDiffUtilsTest {
2928

3029
@Test
31-
publicvoidtestDiff_Insert()throwsDiffException{
30+
publicvoidtestDiff_Insert() {
3231
finalPatch<String>patch =DiffUtils.diff(Arrays.asList("hhh"),Arrays.
3332
asList("hhh","jjj","kkk"));
3433
assertNotNull(patch);
@@ -40,7 +39,7 @@ public void testDiff_Insert() throws DiffException {
4039
}
4140

4241
@Test
43-
publicvoidtestDiff_Delete()throwsDiffException{
42+
publicvoidtestDiff_Delete() {
4443
finalPatch<String>patch =DiffUtils.diff(Arrays.asList("ddd","fff","ggg"),Arrays.
4544
asList("ggg"));
4645
assertNotNull(patch);
@@ -52,7 +51,7 @@ public void testDiff_Delete() throws DiffException {
5251
}
5352

5453
@Test
55-
publicvoidtestDiff_Change()throwsDiffException{
54+
publicvoidtestDiff_Change() {
5655
finalList<String>changeTest_from =Arrays.asList("aaa","bbb","ccc");
5756
finalList<String>changeTest_to =Arrays.asList("aaa","zzz","ccc");
5857

@@ -66,14 +65,14 @@ public void testDiff_Change() throws DiffException {
6665
}
6766

6867
@Test
69-
publicvoidtestDiff_EmptyList()throwsDiffException{
68+
publicvoidtestDiff_EmptyList() {
7069
finalPatch<String>patch =DiffUtils.diff(newArrayList<>(),newArrayList<>());
7170
assertNotNull(patch);
7271
assertEquals(0,patch.getDeltas().size());
7372
}
7473

7574
@Test
76-
publicvoidtestDiff_EmptyListWithNonEmpty()throwsDiffException{
75+
publicvoidtestDiff_EmptyListWithNonEmpty() {
7776
finalPatch<String>patch =DiffUtils.diff(newArrayList<>(),Arrays.asList("aaa"));
7877
assertNotNull(patch);
7978
assertEquals(1,patch.getDeltas().size());
@@ -82,7 +81,7 @@ public void testDiff_EmptyListWithNonEmpty() throws DiffException {
8281
}
8382

8483
@Test
85-
publicvoidtestDiffInline()throwsDiffException{
84+
publicvoidtestDiffInline() {
8685
finalPatch<String>patch =DiffUtils.diffInline("","test");
8786
assertEquals(1,patch.getDeltas().size());
8887
assertTrue(patch.getDeltas().get(0)instanceofInsertDelta);
@@ -92,7 +91,7 @@ public void testDiffInline() throws DiffException {
9291
}
9392

9493
@Test
95-
publicvoidtestDiffInline2()throwsDiffException{
94+
publicvoidtestDiffInline2() {
9695
finalPatch<String>patch =DiffUtils.diffInline("es","fest");
9796
assertEquals(2,patch.getDeltas().size());
9897
assertTrue(patch.getDeltas().get(0)instanceofInsertDelta);
@@ -105,7 +104,7 @@ public void testDiffInline2() throws DiffException {
105104
}
106105

107106
@Test
108-
publicvoidtestDiffIntegerList()throwsDiffException{
107+
publicvoidtestDiffIntegerList() {
109108
List<Integer>original =Arrays.asList(1,2,3,4,5);
110109
List<Integer>revised =Arrays.asList(2,3,4,6);
111110

@@ -121,7 +120,7 @@ public void testDiffIntegerList() throws DiffException {
121120
}
122121

123122
@Test
124-
publicvoidtestDiffMissesChangeForkDnaumenkoIssue31()throwsDiffException{
123+
publicvoidtestDiffMissesChangeForkDnaumenkoIssue31() {
125124
List<String>original =Arrays.asList("line1","line2","line3");
126125
List<String>revised =Arrays.asList("line1","line2-2","line4");
127126

@@ -135,7 +134,7 @@ public void testDiffMissesChangeForkDnaumenkoIssue31() throws DiffException {
135134
*/
136135
@Test
137136
@Disabled
138-
publicvoidtestPossibleDiffHangOnLargeDatasetDnaumenkoIssue26()throwsIOException,DiffException {
137+
publicvoidtestPossibleDiffHangOnLargeDatasetDnaumenkoIssue26()throwsIOException {
139138
ZipFilezip =newZipFile(TestConstants.MOCK_FOLDER +"/large_dataset1.zip");
140139

141140
Patch<String>patch =DiffUtils.diff(
@@ -154,7 +153,7 @@ public static List<String> readStringListFromInputStream(InputStream is) throws
154153
}
155154

156155
@Test
157-
publicvoidtestDiffMyersExample1()throwsDiffException{
156+
publicvoidtestDiffMyersExample1() {
158157
finalPatch<String>patch =DiffUtils.diff(Arrays.asList("A","B","C","A","B","B","A"),Arrays.asList("C","B","A","B","A","C"));
159158
assertNotNull(patch);
160159
assertEquals(4,patch.getDeltas().size());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp