Search in sources :

Example 21 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class UtilTest method testConcatenateEquals.

public void testConcatenateEquals() {
    prepareForFragments();
    DiffFragment fragments = Util.concatenate(new DiffFragment[] { new DiffFragment("a", "a"), DiffFragment.unchanged("1", "XY"), DiffFragment.unchanged("2\n3", "Q\nW\nE") });
    assertTrue(fragments.isEqual());
    assertFalse(fragments.isOneSide());
    assertEquals("a12\n3", fragments.getText1());
    assertEquals("aXYQ\nW\nE", fragments.getText2());
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 22 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method testLeadingFormatting.

public void testLeadingFormatting() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments(" abc\n 123", " 123");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(" abc\n", null), new DiffFragment(" 123", " 123") }, UniteSameType.INSTANCE.correct(fragments));
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 23 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method test4.

public void test4() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments("  abc\n2222\n", "    x = abc\nzzzz\n");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(null, "  "), new DiffFragment("  ", "  "), new DiffFragment(null, "x"), new DiffFragment(null, " ="), new DiffFragment(null, " "), new DiffFragment("abc\n", "abc\n"), new DiffFragment("2222", "zzzz"), new DiffFragment("\n", "\n") }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 24 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method test1.

public void test1() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments("abc def, 123", "ab def, 12");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment("abc", "ab"), new DiffFragment(" def, ", " def, "), new DiffFragment("123", "12") }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 25 with DiffFragment

use of com.intellij.openapi.diff.ex.DiffFragment in project intellij-community by JetBrains.

the class ByWordTest method testRestyleNewLines.

public void testRestyleNewLines() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments("f(a, b);", "f(a,\n  b);");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment("f(a,", "f(a,"), new DiffFragment(" ", "\n  "), new DiffFragment("b);", "b);") }, UniteSameType.INSTANCE.correct(fragments));
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Aggregations

DiffFragment (com.intellij.openapi.diff.ex.DiffFragment)55 DiffString (com.intellij.openapi.diff.impl.string.DiffString)15 NotNull (org.jetbrains.annotations.NotNull)13 FragmentSide (com.intellij.openapi.diff.impl.highlighting.FragmentSide)3 LineFragment (com.intellij.openapi.diff.impl.fragments.LineFragment)2 TextRange (com.intellij.openapi.util.TextRange)2 FilesTooBigForDiffException (com.intellij.util.diff.FilesTooBigForDiffException)2 Fragment (com.intellij.openapi.diff.impl.fragments.Fragment)1 DiffCorrection (com.intellij.openapi.diff.impl.processing.DiffCorrection)1 DiffFragmentsProcessor (com.intellij.openapi.diff.impl.processing.DiffFragmentsProcessor)1 Document (com.intellij.openapi.editor.Document)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Diff (com.intellij.util.diff.Diff)1 ArrayList (java.util.ArrayList)1