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

Cleanups#30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wumpz merged 8 commits intojava-diff-utils:masterfromskitt:cleanups
Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletionssrc/main/java/com/github/difflib/DiffUtils.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Objects;
import java.util.function.BiPredicate;
import static java.util.stream.Collectors.joining;

/**
* Implements the difference and patching engine
Expand DownExpand Up@@ -143,7 +142,7 @@ private static List<String> compressLines(List<String> lines, String delimiter)
if (lines.isEmpty()) {
return Collections.emptyList();
}
return Collections.singletonList(lines.stream().collect(joining(delimiter)));
return Collections.singletonList(String.join(delimiter, lines));
}

/**
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,8 @@
/**
* Thrown whenever the differencing engine cannot produce the differences between two revisions of ta text.
*
* @see MyersDiff
* @seedifflib.DiffAlgorithm
* @seecom.github.difflib.algorithm.myers.MyersDiff
* @seeDiffAlgorithmI
*/
public class DifferentiationFailedException extends DiffException {

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,6 @@
import com.github.difflib.algorithm.Change;
import com.github.difflib.algorithm.DiffAlgorithmI;
import com.github.difflib.algorithm.DiffAlgorithmListener;
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.DeltaType;
import java.util.ArrayList;
import java.util.List;
Expand All@@ -37,7 +36,7 @@
public class HistogramDiff<T> implements DiffAlgorithmI<T> {

@Override
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress)throws DiffException{
public List<Change> computeDiff(List<T> source, List<T> target, DiffAlgorithmListener progress) {
Objects.requireNonNull(source, "source list must not be null");
Objects.requireNonNull(target, "target list must not be null");
if (progress != null) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -138,7 +138,7 @@ private PathNode buildPath(final List<T> orig, final List<T> rev, DiffAlgorithmL
/**
* Constructs a {@link Patch} from a difference path.
*
* @parampath The path.
* @paramactualPath The path.
* @param orig The original sequence.
* @param rev The revised sequence.
* @return A {@link Patch} script corresponding to the path.
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,10 +19,6 @@
* A node in a diffpath.
*
* @author <a href="mailto:juanco@suigeneris.org">Juanco Anez</a>
*
* @see DiffNode
* @see Snake
*
*/
public final class PathNode {

Expand DownExpand Up@@ -78,10 +74,10 @@ public boolean isBootstrap() {
}

/**
* Skips sequences of {@linkDiffNode DiffNodes} until a{@link Snake} or bootstrap node is found, or the end of the
* Skips sequences of {@linkPathNode PathNodes} until asnake or bootstrap node is found, or the end of the
* path is reached.
*
* @return The next first {@linkSnake} or bootstrap node in the path, or <code>null</code> if none found.
* @return The next first {@linkPathNode} or bootstrap node in the path, or <code>null</code> if none found.
*/
public final PathNode previousSnake() {
if (isBootstrap()) {
Expand All@@ -102,9 +98,9 @@ public String toString() {
PathNode node = this;
while (node != null) {
buf.append("(");
buf.append(Integer.toString(node.i));
buf.append(node.i);
buf.append(",");
buf.append(Integer.toString(node.j));
buf.append(node.j);
buf.append(")");
node = node.prev;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@
* Describes the change-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @paramT The type of the compared elements in the data 'lines'.
* @param<T> The type of the compared elements in the data 'lines'.
*/
public final class ChangeDelta<T> extends AbstractDelta<T> {

Expand Down
2 changes: 1 addition & 1 deletionsrc/main/java/com/github/difflib/patch/Chunk.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,7 +29,7 @@
* </p>
*
* @author <a href="dm.naumenko@gmail.com>Dmitry Naumenko</a>
* @paramT The type of the compared elements in the 'lines'.
* @param<T> The type of the compared elements in the 'lines'.
*/
public final class Chunk<T> {

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@
* Describes the delete-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @paramT The type of the compared elements in the 'lines'.
* @param<T> The type of the compared elements in the 'lines'.
*/
public final class DeleteDelta<T> extends AbstractDelta<T> {

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@
* Describes the add-delta between original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @paramT The type of the compared elements in the 'lines'.
* @param<T> The type of the compared elements in the 'lines'.
*/
public final class InsertDelta<T> extends AbstractDelta<T> {

Expand Down
9 changes: 3 additions & 6 deletionssrc/main/java/com/github/difflib/patch/Patch.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,20 +19,17 @@
*/
package com.github.difflib.patch;

import static java.util.Comparator.comparing;
import com.github.difflib.algorithm.Change;
import static com.github.difflib.patch.DeltaType.DELETE;
import static com.github.difflib.patch.DeltaType.INSERT;
import java.util.ArrayList;
import java.util.Collections;
import static java.util.Comparator.comparing;
import java.util.List;
import java.util.ListIterator;

/**
* Describes the patch holding all deltas between the original and revised texts.
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @paramT The type of the compared elements in the 'lines'.
* @param<T> The type of the compared elements in the 'lines'.
*/
public final class Patch<T> {

Expand DownExpand Up@@ -93,7 +90,7 @@ public void addDelta(AbstractDelta<T> delta) {
* @return the deltas
*/
public List<AbstractDelta<T>> getDeltas() {
Collections.sort(deltas,comparing(d -> d.getSource().getPosition()));
deltas.sort(comparing(d -> d.getSource().getPosition()));
return deltas;
}

Expand Down
13 changes: 5 additions & 8 deletionssrc/main/java/com/github/difflib/text/DiffRowGenerator.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,8 +98,7 @@ protected final static List<String> splitStringPreserveDelimiter(String str, Pat
*
* @param startPosition the position from which tag should start. The counting start from a zero.
* @param endPosition the position before which tag should should be closed.
* @param tag the tag name without angle brackets, just a word
* @param cssClass the optional css class
* @param tagGenerator the tag generator
*/
static void wrapInTag(List<String> sequence, int startPosition,
int endPosition, Function<Boolean, String> tagGenerator) {
Expand DownExpand Up@@ -179,16 +178,14 @@ public List<DiffRow> generateDiffRows(List<String> original, List<String> revise
* for displaying side-by-side diff.
*
* @param original the original text
* @param revised the revised text
* @param patch the given patch
* @return the DiffRows between original and revised texts
*/
public List<DiffRow> generateDiffRows(final List<String> original, Patch<String> patch) throws DiffException {
List<DiffRow> diffRows = new ArrayList<>();
int endPos = 0;
final List<AbstractDelta<String>> deltaList = patch.getDeltas();
for (int i = 0; i < deltaList.size(); i++) {
AbstractDelta<String> delta = deltaList.get(i);
for (AbstractDelta<String> delta : deltaList) {
Chunk<String> orig = delta.getSource();
Chunk<String> rev = delta.getTarget();

Expand All@@ -199,7 +196,7 @@ public List<DiffRow> generateDiffRows(final List<String> original, Patch<String>
// Inserted DiffRow
if (delta instanceof InsertDelta) {
endPos = orig.last() + 1;
for (String line :(List<String>)rev.getLines()) {
for (String line : rev.getLines()) {
diffRows.add(buildDiffRow(Tag.INSERT, "", line));
}
continue;
Expand All@@ -208,7 +205,7 @@ public List<DiffRow> generateDiffRows(final List<String> original, Patch<String>
// Deleted DiffRow
if (delta instanceof DeleteDelta) {
endPos = orig.last() + 1;
for (String line :(List<String>)orig.getLines()) {
for (String line : orig.getLines()) {
diffRows.add(buildDiffRow(Tag.DELETE, line, ""));
}
continue;
Expand DownExpand Up@@ -401,7 +398,7 @@ public Builder reportLinesUnchanged(final boolean val) {
/**
* Generator for Old-Text-Tags.
*
* @paramtag the tagto set. Without angle brackets. Default: span.
* @paramgenerator the taggenerator
* @return builder with configured ignoreBlankLines parameter
*/
public Builder oldTag(Function<Boolean, String> generator) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.junit.Test;

Expand DownExpand Up@@ -113,8 +113,8 @@ private void verify(List<String> origLines, List<String> revLines,
Patch<String> fromUnifiedPatch = UnifiedDiffUtils.parseUnifiedDiff(unifiedDiff);
List<String> patchedLines;
try {
patchedLines =(List<String>)fromUnifiedPatch.applyTo(origLines);
assertTrue(revLines.size() == patchedLines.size());
patchedLines = fromUnifiedPatch.applyTo(origLines);
assertEquals(revLines.size(), patchedLines.size());
for (int i = 0; i < revLines.size(); i++) {
String l1 = revLines.get(i);
String l2 = patchedLines.get(i);
Expand Down
2 changes: 1 addition & 1 deletionsrc/test/java/com/github/difflib/TestConstants.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ public final class TestConstants {

public static final String BASE_FOLDER_RESOURCES = "target/test-classes/";
/**
* The base folder containing the test files. Ends with {@link #FS}.
* The base folder containing the test files.
*/
public static final String MOCK_FOLDER = BASE_FOLDER_RESOURCES + "/mocks/";

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,7 +16,6 @@
package com.github.difflib.algorithm.jgit;

import com.github.difflib.algorithm.DiffAlgorithmListener;
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.util.ArrayList;
Expand DownExpand Up@@ -58,7 +57,7 @@ public void tearDown() {
* Test of diff method, of class HistogramDiff.
*/
@Test
public void testDiff() throwsDiffException,PatchFailedException {
public void testDiff() throws PatchFailedException {
List<String> orgList = Arrays.asList("A", "B", "C", "A", "B", "B", "A");
List<String> revList = Arrays.asList("C", "B", "A", "B", "A", "C");
final Patch<String> patch = Patch.generate(orgList, revList, new HistogramDiff().computeDiff(orgList, revList, null));
Expand All@@ -72,7 +71,7 @@ public void testDiff() throws DiffException, PatchFailedException {
}

@Test
public void testDiffWithListener() throwsDiffException,PatchFailedException {
public void testDiffWithListener() throws PatchFailedException {
List<String> orgList = Arrays.asList("A", "B", "C", "A", "B", "B", "A");
List<String> revList = Arrays.asList("C", "B", "A", "B", "A", "C");

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,7 +18,6 @@
import static com.github.difflib.DiffUtilsTest.readStringListFromInputStream;
import com.github.difflib.TestConstants;
import com.github.difflib.algorithm.DiffAlgorithmListener;
import com.github.difflib.algorithm.DiffException;
import com.github.difflib.patch.Patch;
import com.github.difflib.patch.PatchFailedException;
import java.io.IOException;
Expand DownExpand Up@@ -58,7 +57,7 @@ public void tearDown() {
}

@Test
public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException,DiffException,PatchFailedException {
public void testPossibleDiffHangOnLargeDatasetDnaumenkoIssue26() throws IOException, PatchFailedException {
ZipFile zip = new ZipFile(TestConstants.MOCK_FOLDER + "/large_dataset1.zip");
List<String> original = readStringListFromInputStream(zip.getInputStream(zip.getEntry("ta")));
List<String> revised = readStringListFromInputStream(zip.getInputStream(zip.getEntry("tb")));
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp