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

Commitc7f4dfb

Browse files
committed
fixes#208 - reformatted source code
1 parentde0e157 commitc7f4dfb

File tree

56 files changed

+6881
-6639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+6881
-6639
lines changed

‎java-diff-utils-jgit/pom.xml

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<parent>
5-
<groupId>io.github.java-diff-utils</groupId>
6-
<artifactId>java-diff-utils-parent</artifactId>
7-
<version>4.16-SNAPSHOT</version>
8-
</parent>
9-
<artifactId>java-diff-utils-jgit</artifactId>
10-
<name>java-diff-utils-jgit</name>
11-
<packaging>jar</packaging>
12-
<description>This is an extension of java-diff-utils using jgit to use its implementation of
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>io.github.java-diff-utils</groupId>
6+
<artifactId>java-diff-utils-parent</artifactId>
7+
<version>4.16-SNAPSHOT</version>
8+
</parent>
9+
<artifactId>java-diff-utils-jgit</artifactId>
10+
<packaging>jar</packaging>
11+
<name>java-diff-utils-jgit</name>
12+
<description>This is an extension of java-diff-utils using jgit to use its implementation of
1313
some difference algorithms.</description>
14-
<dependencies>
15-
<dependency>
16-
<groupId>org.junit.jupiter</groupId>
17-
<artifactId>junit-jupiter</artifactId>
18-
<scope>test</scope>
19-
</dependency>
20-
<dependency>
21-
<!-- no upgrade possible till base JDK upgrade to 17-->
22-
<groupId>org.eclipse.jgit</groupId>
23-
<artifactId>org.eclipse.jgit</artifactId>
24-
<version>5.13.3.202401111512-r</version>
25-
<exclusions>
26-
<exclusion>
27-
<groupId>com.googlecode.javaewah</groupId>
28-
<artifactId>JavaEWAH</artifactId>
29-
</exclusion>
30-
<exclusion>
31-
<groupId>commons-codec</groupId>
32-
<artifactId>commons-codec</artifactId>
33-
</exclusion>
34-
<exclusion>
35-
<groupId>commons-logging</groupId>
36-
<artifactId>commons-logging</artifactId>
37-
</exclusion>
38-
<exclusion>
39-
<groupId>org.apache.httpcomponents</groupId>
40-
<artifactId>httpclient</artifactId>
41-
</exclusion>
42-
<exclusion>
43-
<groupId>com.jcraft</groupId>
44-
<artifactId>jsch</artifactId>
45-
</exclusion>
46-
<exclusion>
47-
<groupId>org.slf4j</groupId>
48-
<artifactId>slf4j-api</artifactId>
49-
</exclusion>
50-
</exclusions>
51-
</dependency>
52-
<dependency>
53-
<groupId>${project.groupId}</groupId>
54-
<artifactId>java-diff-utils</artifactId>
55-
<version>${project.version}</version>
56-
</dependency>
57-
</dependencies>
58-
</project>
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.junit.jupiter</groupId>
17+
<artifactId>junit-jupiter</artifactId>
18+
<scope>test</scope>
19+
</dependency>
20+
<dependency>
21+
<!-- no upgrade possible till base JDK upgrade to 17-->
22+
<groupId>org.eclipse.jgit</groupId>
23+
<artifactId>org.eclipse.jgit</artifactId>
24+
<version>5.13.3.202401111512-r</version>
25+
<exclusions>
26+
<exclusion>
27+
<groupId>com.googlecode.javaewah</groupId>
28+
<artifactId>JavaEWAH</artifactId>
29+
</exclusion>
30+
<exclusion>
31+
<groupId>commons-codec</groupId>
32+
<artifactId>commons-codec</artifactId>
33+
</exclusion>
34+
<exclusion>
35+
<groupId>commons-logging</groupId>
36+
<artifactId>commons-logging</artifactId>
37+
</exclusion>
38+
<exclusion>
39+
<groupId>org.apache.httpcomponents</groupId>
40+
<artifactId>httpclient</artifactId>
41+
</exclusion>
42+
<exclusion>
43+
<groupId>com.jcraft</groupId>
44+
<artifactId>jsch</artifactId>
45+
</exclusion>
46+
<exclusion>
47+
<groupId>org.slf4j</groupId>
48+
<artifactId>slf4j-api</artifactId>
49+
</exclusion>
50+
</exclusions>
51+
</dependency>
52+
<dependency>
53+
<groupId>${project.groupId}</groupId>
54+
<artifactId>java-diff-utils</artifactId>
55+
<version>${project.version}</version>
56+
</dependency>
57+
</dependencies>
58+
</project>

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

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -35,71 +35,71 @@
3535
*/
3636
publicclassHistogramDiff<T>implementsDiffAlgorithmI<T> {
3737

38-
@Override
39-
publicList<Change>computeDiff(List<T>source,List<T>target,DiffAlgorithmListenerprogress) {
40-
Objects.requireNonNull(source,"source list must not be null");
41-
Objects.requireNonNull(target,"target list must not be null");
42-
if (progress !=null) {
43-
progress.diffStart();
44-
}
45-
EditListdiffList =newEditList();
46-
diffList.addAll(neworg.eclipse.jgit.diff.HistogramDiff().diff(newDataListComparator<>(progress),newDataList<>(source),newDataList<>(target)));
47-
List<Change>patch =newArrayList<>();
48-
for (Editedit :diffList) {
49-
DeltaTypetype =DeltaType.EQUAL;
50-
switch (edit.getType()) {
51-
caseDELETE:
52-
type =DeltaType.DELETE;
53-
break;
54-
caseINSERT:
55-
type =DeltaType.INSERT;
56-
break;
57-
caseREPLACE:
58-
type =DeltaType.CHANGE;
59-
break;
60-
}
61-
patch.add(newChange(type,edit.getBeginA(),edit.getEndA(),edit.getBeginB(),edit.getEndB()));
62-
}
63-
if (progress !=null) {
64-
progress.diffEnd();
65-
}
66-
returnpatch;
67-
}
38+
@Override
39+
publicList<Change>computeDiff(List<T>source,List<T>target,DiffAlgorithmListenerprogress) {
40+
Objects.requireNonNull(source,"source list must not be null");
41+
Objects.requireNonNull(target,"target list must not be null");
42+
if (progress !=null) {
43+
progress.diffStart();
44+
}
45+
EditListdiffList =newEditList();
46+
diffList.addAll(neworg.eclipse.jgit.diff.HistogramDiff()
47+
.diff(newDataListComparator<>(progress),newDataList<>(source),newDataList<>(target)));
48+
List<Change>patch =newArrayList<>();
49+
for (Editedit :diffList) {
50+
DeltaTypetype =DeltaType.EQUAL;
51+
switch (edit.getType()) {
52+
caseDELETE:
53+
type =DeltaType.DELETE;
54+
break;
55+
caseINSERT:
56+
type =DeltaType.INSERT;
57+
break;
58+
caseREPLACE:
59+
type =DeltaType.CHANGE;
60+
break;
61+
}
62+
patch.add(newChange(type,edit.getBeginA(),edit.getEndA(),edit.getBeginB(),edit.getEndB()));
63+
}
64+
if (progress !=null) {
65+
progress.diffEnd();
66+
}
67+
returnpatch;
68+
}
6869
}
6970

7071
classDataListComparator<T>extendsSequenceComparator<DataList<T>> {
7172

72-
privatefinalDiffAlgorithmListenerprogress;
73+
privatefinalDiffAlgorithmListenerprogress;
7374

74-
publicDataListComparator(DiffAlgorithmListenerprogress) {
75-
this.progress =progress;
76-
}
75+
publicDataListComparator(DiffAlgorithmListenerprogress) {
76+
this.progress =progress;
77+
}
7778

78-
@Override
79-
publicbooleanequals(DataList<T>original,intorgIdx,DataList<T>revised,intrevIdx) {
80-
if (progress !=null) {
81-
progress.diffStep(orgIdx +revIdx,original.size() +revised.size());
82-
}
83-
returnoriginal.data.get(orgIdx).equals(revised.data.get(revIdx));
84-
}
85-
86-
@Override
87-
publicinthash(DataList<T>s,inti) {
88-
returns.data.get(i).hashCode();
89-
}
79+
@Override
80+
publicbooleanequals(DataList<T>original,intorgIdx,DataList<T>revised,intrevIdx) {
81+
if (progress !=null) {
82+
progress.diffStep(orgIdx +revIdx,original.size() +revised.size());
83+
}
84+
returnoriginal.data.get(orgIdx).equals(revised.data.get(revIdx));
85+
}
9086

87+
@Override
88+
publicinthash(DataList<T>s,inti) {
89+
returns.data.get(i).hashCode();
90+
}
9191
}
9292

9393
classDataList<T>extendsSequence {
9494

95-
finalList<T>data;
95+
finalList<T>data;
9696

97-
publicDataList(List<T>data) {
98-
this.data =data;
99-
}
97+
publicDataList(List<T>data) {
98+
this.data =data;
99+
}
100100

101-
@Override
102-
publicintsize() {
103-
returndata.size();
104-
}
101+
@Override
102+
publicintsize() {
103+
returndata.size();
104+
}
105105
}

‎java-diff-utils-jgit/src/test/java/com/github/difflib/algorithm/jgit/HistogramDiffTest.java

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
*/
1616
packagecom.github.difflib.algorithm.jgit;
1717

18+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
19+
importstaticorg.junit.jupiter.api.Assertions.assertNotNull;
20+
1821
importcom.github.difflib.algorithm.DiffAlgorithmListener;
1922
importcom.github.difflib.patch.Patch;
2023
importcom.github.difflib.patch.PatchFailedException;
2124
importjava.util.ArrayList;
2225
importjava.util.Arrays;
2326
importjava.util.List;
24-
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
25-
importstaticorg.junit.jupiter.api.Assertions.assertNotNull;
2627
importorg.junit.jupiter.api.Test;
2728

2829
/**
@@ -31,57 +32,64 @@
3132
*/
3233
publicclassHistogramDiffTest {
3334

34-
publicHistogramDiffTest() {
35-
}
35+
publicHistogramDiffTest() {}
36+
37+
/**
38+
* Test of diff method, of class HistogramDiff.
39+
*/
40+
@Test
41+
publicvoidtestDiff()throwsPatchFailedException {
42+
List<String>orgList =Arrays.asList("A","B","C","A","B","B","A");
43+
List<String>revList =Arrays.asList("C","B","A","B","A","C");
44+
finalPatch<String>patch =
45+
Patch.generate(orgList,revList,newHistogramDiff<String>().computeDiff(orgList,revList,null));
46+
System.out.println(patch);
47+
assertNotNull(patch);
48+
assertEquals(3,patch.getDeltas().size());
49+
assertEquals(
50+
"Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [DeleteDelta, position: 3, lines: [A, B]], [InsertDelta, position: 7, lines: [B, A, C]]]}",
51+
patch.toString());
52+
53+
List<String>patched =patch.applyTo(orgList);
54+
assertEquals(revList,patched);
55+
}
56+
57+
@Test
58+
publicvoidtestDiffWithListener()throwsPatchFailedException {
59+
List<String>orgList =Arrays.asList("A","B","C","A","B","B","A");
60+
List<String>revList =Arrays.asList("C","B","A","B","A","C");
3661

37-
/**
38-
* Test of diff method, of class HistogramDiff.
39-
*/
40-
@Test
41-
publicvoidtestDiff()throwsPatchFailedException {
42-
List<String>orgList =Arrays.asList("A","B","C","A","B","B","A");
43-
List<String>revList =Arrays.asList("C","B","A","B","A","C");
44-
finalPatch<String>patch =Patch.generate(orgList,revList,newHistogramDiff<String>().computeDiff(orgList,revList,null));
45-
System.out.println(patch);
46-
assertNotNull(patch);
47-
assertEquals(3,patch.getDeltas().size());
48-
assertEquals("Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [DeleteDelta, position: 3, lines: [A, B]], [InsertDelta, position: 7, lines: [B, A, C]]]}",patch.toString());
62+
List<String>logdata =newArrayList<>();
63+
finalPatch<String>patch =Patch.generate(
64+
orgList,
65+
revList,
66+
newHistogramDiff<String>().computeDiff(orgList,revList,newDiffAlgorithmListener() {
67+
@Override
68+
publicvoiddiffStart() {
69+
logdata.add("start");
70+
}
4971

50-
List<String>patched =patch.applyTo(orgList);
51-
assertEquals(revList,patched);
52-
}
53-
54-
@Test
55-
publicvoidtestDiffWithListener()throwsPatchFailedException {
56-
List<String>orgList =Arrays.asList("A","B","C","A","B","B","A");
57-
List<String>revList =Arrays.asList("C","B","A","B","A","C");
58-
59-
List<String>logdata =newArrayList<>();
60-
finalPatch<String>patch =Patch.generate(orgList,revList,newHistogramDiff<String>().computeDiff(orgList,revList,newDiffAlgorithmListener() {
61-
@Override
62-
publicvoiddiffStart() {
63-
logdata.add("start");
64-
}
72+
@Override
73+
publicvoiddiffStep(intvalue,intmax) {
74+
logdata.add(value +" - " +max);
75+
}
6576

66-
@Override
67-
publicvoiddiffStep(intvalue,intmax) {
68-
logdata.add(value +" - " +max);
69-
}
77+
@Override
78+
publicvoiddiffEnd() {
79+
logdata.add("end");
80+
}
81+
}));
82+
System.out.println(patch);
83+
assertNotNull(patch);
84+
assertEquals(3,patch.getDeltas().size());
85+
assertEquals(
86+
"Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [DeleteDelta, position: 3, lines: [A, B]], [InsertDelta, position: 7, lines: [B, A, C]]]}",
87+
patch.toString());
7088

71-
@Override
72-
publicvoiddiffEnd() {
73-
logdata.add("end");
74-
}
75-
}));
76-
System.out.println(patch);
77-
assertNotNull(patch);
78-
assertEquals(3,patch.getDeltas().size());
79-
assertEquals("Patch{deltas=[[DeleteDelta, position: 0, lines: [A, B]], [DeleteDelta, position: 3, lines: [A, B]], [InsertDelta, position: 7, lines: [B, A, C]]]}",patch.toString());
89+
List<String>patched =patch.applyTo(orgList);
90+
assertEquals(revList,patched);
8091

81-
List<String>patched =patch.applyTo(orgList);
82-
assertEquals(revList,patched);
83-
84-
System.out.println(logdata);
85-
assertEquals(19,logdata.size());
86-
}
92+
System.out.println(logdata);
93+
assertEquals(19,logdata.size());
94+
}
8795
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp