本文整理汇总了Java中org.eclipse.jgit.diff.EditList.addAll方法的典型用法代码示例。如果您正苦于以下问题:Java EditList.addAll方法的具体用法?Java EditList.addAll怎么用?Java EditList.addAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.diff.EditList
的用法示例。
在下文中一共展示了EditList.addAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diff
import org.eclipse.jgit.diff.EditList; //导入方法依赖的package包/类
@Override
public List<Change> diff(List<T> original, List<T> revised) throws DiffException {
Objects.requireNonNull(original, "original list must not be null");
Objects.requireNonNull(revised, "revised list must not be null");
EditList diffList = new EditList();
diffList.addAll(new org.eclipse.jgit.diff.HistogramDiff().diff(new DataListComparator<>(), new DataList<>(original), new DataList<>(revised)));
List<Change> patch = new ArrayList<>();
for (Edit edit : diffList) {
DeltaType type = DeltaType.EQUAL;
switch (edit.getType()) {
case DELETE:
type = DeltaType.DELETE;
break;
case INSERT:
type = DeltaType.INSERT;
break;
case REPLACE:
type = DeltaType.CHANGE;
break;
}
patch.add(new Change(type, edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB()));
}
return patch;
}
示例2: diffWhitespaceLineEndings
import org.eclipse.jgit.diff.EditList; //导入方法依赖的package包/类
/**
* Returns a git-style diff between the two unix strings.
*
* Output has no trailing newlines.
*
* Boolean args determine whether whitespace or line endings will be visible.
*/
private static String diffWhitespaceLineEndings(String dirty, String clean, boolean whitespace, boolean lineEndings) throws IOException {
dirty = visibleWhitespaceLineEndings(dirty, whitespace, lineEndings);
clean = visibleWhitespaceLineEndings(clean, whitespace, lineEndings);
RawText a = new RawText(dirty.getBytes(StandardCharsets.UTF_8));
RawText b = new RawText(clean.getBytes(StandardCharsets.UTF_8));
EditList edits = new EditList();
edits.addAll(MyersDiff.INSTANCE.diff(RawTextComparator.DEFAULT, a, b));
ByteArrayOutputStream out = new ByteArrayOutputStream();
try (DiffFormatter formatter = new DiffFormatter(out)) {
formatter.format(edits, a, b);
}
String formatted = out.toString(StandardCharsets.UTF_8.name());
// we don't need the diff to show this, since we display newlines ourselves
formatted = formatted.replace("\\ No newline at end of file\n", "");
return NEWLINE_MATCHER.trimTrailingFrom(formatted);
}