Skip to content

Commit

Permalink
Moving PatchParser from violation-comments-lib #95
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 6, 2020
1 parent 5366904 commit 5c52a39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PatchParser {
public class PatchParserUtil {

private static final Pattern RANGE_PATTERN =
Pattern.compile(
Expand All @@ -18,7 +18,7 @@ public class PatchParser {
private final Map<Integer, Optional<Integer>> newLineToOldLineTable;
private final Map<Integer, Optional<Integer>> newLineToLineInDiffTable;

public PatchParser(String patchString) {
public PatchParserUtil(String patchString) {
newLineToOldLineTable = new TreeMap<>();
newLineToLineInDiffTable = new TreeMap<>();
if (patchString == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.util.logging.Logger;
import org.junit.Test;

public class PatchParserTest {
private static Logger LOG = Logger.getLogger(PatchParser.class.getSimpleName());
public class PatchParserUtilTest {
private static Logger LOG = Logger.getLogger(PatchParserUtil.class.getSimpleName());

private static final String NEW_DIFF =
"@@ -1,6 +1,6 @@\n <html>\n <head></head>\n <body>\n-<font>\n+<font> \n </body> \n </html>";
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testThatOldLineIsEmptyIfOutsideOfDiff() {

getIntegerOptionalMap(patch);

final PatchParser pp = new PatchParser(patch);
final PatchParserUtil pp = new PatchParserUtil(patch);

assertThat(pp.isLineInDiff(999)) //
.isFalse();
Expand Down Expand Up @@ -124,7 +124,7 @@ public void testThatLineTableCanBeRetrieved2() {
private Integer findLineToComment(String patch, int commentLint) {
getIntegerOptionalMap(patch);

return new PatchParser(patch) //
return new PatchParserUtil(patch) //
.findLineInDiff(commentLint) //
.orElse(null);
}
Expand All @@ -136,7 +136,7 @@ private Map<Integer, Optional<Integer>> getIntegerOptionalMap(final String patch
sb.append(i + 1 + " | " + diffLines[i] + "\n");
}
final Map<Integer, Optional<Integer>> map =
new PatchParser(patch) //
new PatchParserUtil(patch) //
.getNewLineToOldLineTable();
for (Map.Entry<Integer, Optional<Integer>> e : map.entrySet()) {
sb.append(e.getKey() + " : " + e.getValue().orElse(null) + "\n");
Expand Down

0 comments on commit 5c52a39

Please sign in to comment.