Skip to content

Commit 4a83032

Browse files
committed
1 parent 983ec68 commit 4a83032

File tree

4 files changed

+98
-14
lines changed

4 files changed

+98
-14
lines changed

src/main/java/com/github/difflib/unifieddiff/UnifiedDiffParser.java renamed to src/main/java/com/github/difflib/unifieddiff/UnifiedDiffReader.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
*
3636
* @author Tobias Warneke (t.warneke@gmx.net)
3737
*/
38-
public final class UnifiedDiffParser {
38+
public final class UnifiedDiffReader {
3939

4040
static final Pattern UNIFIED_DIFF_CHUNK_REGEXP = Pattern.compile("^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
4141

42-
private final UnifiedDiffReader READER;
42+
private final InternalUnifiedDiffReader READER;
4343
private final UnifiedDiff data = new UnifiedDiff();
4444
private final UnifiedDiffLine[] MAIN_PARSER_RULES = new UnifiedDiffLine[]{
4545
new UnifiedDiffLine(true, "^diff\\s", this::processDiff),
@@ -54,8 +54,8 @@ public final class UnifiedDiffParser {
5454

5555
private UnifiedDiffFile actualFile;
5656

57-
UnifiedDiffParser(Reader reader) {
58-
this.READER = new UnifiedDiffReader(reader);
57+
UnifiedDiffReader(Reader reader) {
58+
this.READER = new InternalUnifiedDiffReader(reader);
5959
}
6060

6161
// schema = [[/^\s+/, normal], [/^diff\s/, start], [/^new file mode \d+$/, new_file],
@@ -103,10 +103,10 @@ static String[] parseFileNames(String line) {
103103
};
104104
}
105105

106-
private static final Logger LOG = Logger.getLogger(UnifiedDiffParser.class.getName());
106+
private static final Logger LOG = Logger.getLogger(UnifiedDiffReader.class.getName());
107107

108108
public static UnifiedDiff parseUnifiedDiff(InputStream stream) throws IOException, UnifiedDiffParserException {
109-
UnifiedDiffParser parser = new UnifiedDiffParser(new BufferedReader(new InputStreamReader(stream)));
109+
UnifiedDiffReader parser = new UnifiedDiffReader(new BufferedReader(new InputStreamReader(stream)));
110110
return parser.parse();
111111
}
112112

@@ -244,11 +244,11 @@ public boolean isStopsHeaderParsing() {
244244
}
245245
}
246246

247-
class UnifiedDiffReader extends BufferedReader {
247+
class InternalUnifiedDiffReader extends BufferedReader {
248248

249249
private String lastLine;
250250

251-
public UnifiedDiffReader(Reader reader) {
251+
public InternalUnifiedDiffReader(Reader reader) {
252252
super(reader);
253253
}
254254

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2019 java-diff-utils.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.difflib.unifieddiff;
17+
18+
import java.io.Writer;
19+
20+
/**
21+
*
22+
* @author Tobias Warneke (t.warneke@gmx.net)
23+
*/
24+
public class UnifiedDiffWriter {
25+
26+
public static void write(UnifiedDiff diff, Writer writer) {
27+
28+
}
29+
}

src/test/java/com/github/difflib/unifieddiff/UnifiedDiffParserTest.java renamed to src/test/java/com/github/difflib/unifieddiff/UnifiedDiffReaderTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
*
3232
* @author Tobias Warneke (t.warneke@gmx.net)
3333
*/
34-
public class UnifiedDiffParserTest {
34+
public class UnifiedDiffReaderTest {
3535

36-
public UnifiedDiffParserTest() {
36+
public UnifiedDiffReaderTest() {
3737
}
3838

3939
@BeforeClass
@@ -54,7 +54,7 @@ public void tearDown() {
5454

5555
@Test
5656
public void testSimpleParse() throws IOException {
57-
UnifiedDiff diff = UnifiedDiffParser.parseUnifiedDiff(UnifiedDiffParserTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
57+
UnifiedDiff diff = UnifiedDiffReader.parseUnifiedDiff(UnifiedDiffReaderTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
5858

5959
System.out.println(diff);
6060

@@ -69,13 +69,13 @@ public void testSimpleParse() throws IOException {
6969

7070
@Test
7171
public void testParseDiffBlock() {
72-
String[] files = UnifiedDiffParser.parseFileNames("diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
72+
String[] files = UnifiedDiffReader.parseFileNames("diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
7373
assertThat(files).containsExactly("src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java", "src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java");
7474
}
7575

7676
@Test
7777
public void testChunkHeaderParsing() {
78-
Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
78+
Pattern pattern = UnifiedDiffReader.UNIFIED_DIFF_CHUNK_REGEXP;
7979
Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */");
8080

8181
assertTrue(matcher.find());
@@ -86,7 +86,7 @@ public void testChunkHeaderParsing() {
8686
@Test
8787
public void testChunkHeaderParsing2() {
8888
//"^@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@.*$"
89-
Pattern pattern = UnifiedDiffParser.UNIFIED_DIFF_CHUNK_REGEXP;
89+
Pattern pattern = UnifiedDiffReader.UNIFIED_DIFF_CHUNK_REGEXP;
9090
Matcher matcher = pattern.matcher("@@ -189,6 +189,7 @@");
9191

9292
assertTrue(matcher.find());
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2019 java-diff-utils.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.github.difflib.unifieddiff;
17+
18+
import org.junit.After;
19+
import org.junit.AfterClass;
20+
import org.junit.Before;
21+
import org.junit.BeforeClass;
22+
import org.junit.Test;
23+
24+
/**
25+
*
26+
* @author Tobias Warneke (t.warneke@gmx.net)
27+
*/
28+
public class UnifiedDiffWriterTest {
29+
30+
public UnifiedDiffWriterTest() {
31+
}
32+
33+
@BeforeClass
34+
public static void setUpClass() {
35+
}
36+
37+
@AfterClass
38+
public static void tearDownClass() {
39+
}
40+
41+
@Before
42+
public void setUp() {
43+
}
44+
45+
@After
46+
public void tearDown() {
47+
}
48+
49+
@Test
50+
public void testSomeMethod() {
51+
// TODO review the generated test code and remove the default call to fail.
52+
fail("The test case is a prototype.");
53+
}
54+
55+
}

0 commit comments

Comments
 (0)