当前位置: 首页>>代码示例>>Java>>正文


Java EditList.addAll方法代码示例

本文整理汇总了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;
}
 
开发者ID:wumpz,项目名称:java-diff-utils,代码行数:25,代码来源:HistogramDiff.java

示例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);
}
 
开发者ID:diffplug,项目名称:spotless,代码行数:27,代码来源:DiffMessageFormatter.java


注:本文中的org.eclipse.jgit.diff.EditList.addAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。