Search in sources :

Example 51 with DiffFragment

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

the class NormalizationTest method testUnitesEquals.

public void testUnitesEquals() throws FilesTooBigForDiffException {
    DiffCorrection correction = DiffCorrection.Normalize.INSTANCE;
    DiffFragment[] fragments = correction.correct(new DiffFragment[] { new DiffFragment(null, "a"), new DiffFragment("x", "x"), new DiffFragment("y", "y"), new DiffFragment("z", null), new DiffFragment(null, "z") });
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(null, "a"), new DiffFragment("xyz", "xyz") }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 52 with DiffFragment

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

the class UniteSameTypeTest method testUniteEqualsUnitesFormattingOnly.

public void testUniteEqualsUnitesFormattingOnly() throws FilesTooBigForDiffException {
    DiffFragment changed = new DiffFragment("abc", "123");
    DiffFragment equal = new DiffFragment("qqq", "qqq");
    DiffFragment[] fragments = DiffCorrection.UnitEquals.INSTANCE.correct(new DiffFragment[] { changed, new DiffFragment(" xxx", "xxx"), new DiffFragment("yyy", "  yyy"), equal });
    CHECK.compareAll(new DiffFragment[] { changed, new DiffFragment(" xxxyyy", "xxx  yyy"), equal }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 53 with DiffFragment

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

the class ByWordTest method testIdea58505Trim.

public void testIdea58505Trim() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.TRIM_SPACE);
    DiffFragment[] fragments = byWord.buildFragments("   if (eventMerger!=null && !dataSelection.getValueIsAdjusting()) {", "   if (eventMerger!=null && (dataSelection==null || !dataSelection.getValueIsAdjusting())) {");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment("   if (eventMerger!=null && ", "   if (eventMerger!=null && "), new DiffFragment("!", "("), new DiffFragment("dataSelection", "dataSelection"), new DiffFragment(null, "=="), new DiffFragment(null, "null || !dataSelection"), new DiffFragment(".getValueIsAdjusting())", ".getValueIsAdjusting())"), new DiffFragment(null, ")"), new DiffFragment(" {", " {") }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 54 with DiffFragment

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

the class ByWordTest method test2.

public void test2() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments(" a[xy]+1", ",a[]+1");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(" ", null), new DiffFragment(null, ","), new DiffFragment("a[", "a["), new DiffFragment("xy", null), new DiffFragment("]+1", "]+1") }, fragments);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 55 with DiffFragment

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

the class ByWordTest method test3.

public void test3() throws FilesTooBigForDiffException {
    DiffPolicy byWord = new ByWord(ComparisonPolicy.DEFAULT);
    DiffFragment[] fragments = byWord.buildFragments("0987\n  a.g();\n", "yyyy\n");
    CHECK.compareAll(new DiffFragment[] { new DiffFragment("0987\n  a.g();\n", "yyyy\n") }, 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