use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.
the class TodoCheckinHandlerWorker method getLineFragments.
private static ArrayList<LineFragment> getLineFragments(final String fileName, String beforeContent, String afterContent) throws VcsException {
try {
DiffFragment[] woFormattingBlocks = DiffPolicy.LINES_WO_FORMATTING.buildFragments(DiffString.create(beforeContent), DiffString.create(afterContent));
DiffFragment[] step1lineFragments = new DiffCorrection.TrueLineBlocks(ComparisonPolicy.IGNORE_SPACE).correctAndNormalize(woFormattingBlocks);
return new DiffFragmentsProcessor().process(step1lineFragments);
} catch (FilesTooBigForDiffException e) {
throw new VcsException("File " + fileName + " is too big and there are too many changes to build a diff", e);
}
}
use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.
the class FragmentEquality method equals.
@Override
public boolean equals(Object o1, Object o2) {
DiffFragment fragment1 = (DiffFragment) o1;
DiffFragment fragment2 = (DiffFragment) o2;
return Comparing.equal(fragment1.getText1(), fragment2.getText1()) && Comparing.equal(fragment1.getText2(), fragment2.getText2()) && fragment1.isModified() == fragment2.isModified();
}
use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.
the class LineBlockDividesTest method testSingleSide.
public void testSingleSide() {
DiffFragment abc_ = new DiffFragment("abc", null);
DiffFragment xyzL_ = new DiffFragment("xyz\n", null);
DiffFragment x_y = new DiffFragment("x", "y");
DiffFragment a_b = new DiffFragment("a", "b");
DiffFragment xyzL_L = new DiffFragment("xyz\n", "\n");
DiffFragment abcL_ = new DiffFragment("abc\n", null);
DiffFragment[][] lineBlocks = LineBlockDivider.SINGLE_SIDE.divide(new DiffFragment[] { abc_, xyzL_, x_y, a_b, xyzL_L, abcL_ });
CHECK.compareAll(new DiffFragment[][] { new DiffFragment[] { abc_, xyzL_ }, new DiffFragment[] { x_y, a_b, xyzL_L }, new DiffFragment[] { abcL_ } }, lineBlocks);
}
use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.
the class UtilTest method testSplitByUnchagedNewLine.
public void testSplitByUnchagedNewLine() {
prepareForFragments();
DiffFragment a_b = new DiffFragment("a", "b");
DiffFragment x_x = new DiffFragment("x", "x");
DiffFragment cl_dl = new DiffFragment("c\n", "d\n");
DiffFragment yl_yl = new DiffFragment("y\n", "y\n");
DiffFragment zl_z = new DiffFragment("z\n", "z");
DiffFragment z_zl = new DiffFragment("z", "z\n");
DiffFragment al_ = new DiffFragment("a\n", null);
DiffFragment _al = new DiffFragment(null, "a\n");
DiffFragment[] originalFragments = new DiffFragment[] { a_b, x_x, cl_dl, a_b, yl_yl, x_x, zl_z, z_zl, yl_yl, new DiffFragment("y\nx", "y\nx"), a_b, al_, _al };
CHECK.compareAll(new DiffFragment[][] { new DiffFragment[] { a_b, x_x, cl_dl, a_b, yl_yl }, new DiffFragment[] { x_x, zl_z, z_zl, yl_yl }, new DiffFragment[] { yl_yl }, new DiffFragment[] { x_x, a_b, al_, _al } }, Util.splitByUnchangedLines(originalFragments));
CHECK.compareAll(new DiffFragment[][] { new DiffFragment[] { new DiffFragment("abc\n", "abc\n") }, new DiffFragment[] { DiffFragment.unchanged("123\n", "123") } }, Util.splitByUnchangedLines(new DiffFragment[] { DiffFragment.unchanged("abc\n123\n", "abc\n123") }));
CHECK.compareAll(new DiffFragment[][] { new DiffFragment[] { DiffFragment.unchanged("a\n ", "a") } }, Util.splitByUnchangedLines(new DiffFragment[] { DiffFragment.unchanged("a\n ", "a") }));
}
use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.
the class UtilTest method testUnit.
public void testUnit() {
DiffFragment fragment = Util.unite(new DiffFragment("1", "2"), new DiffFragment("a", "b"));
assertEquals("1a", fragment.getText1());
assertEquals("2b", fragment.getText2());
assertTrue(fragment.isModified());
fragment = Util.unite(new DiffFragment("1", "1"), DiffFragment.unchanged(" ", ""));
assertEquals("1 ", fragment.getText1());
assertEquals("1", fragment.getText2());
assertTrue(fragment.isEqual());
fragment = Util.unite(new DiffFragment("1", null), new DiffFragment("2", null));
assertEquals("12", fragment.getText1());
assertNull(fragment.getText2());
}
Aggregations