Search in sources :

Example 16 with DiffFragment

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

the class DiffFragmentBuilder method change.

private void change(@NotNull TextRange range1, @NotNull TextRange range2) {
    LOG.debug("DiffFragmentBuilder.change(" + range1 + "," + range2 + ")");
    DiffString text1 = null, text2 = null;
    int start1 = range1.getStartOffset();
    int end1 = range1.getEndOffset();
    int start2 = range2.getStartOffset();
    int end2 = range2.getEndOffset();
    if (myLastLine1 < start1) {
        text1 = concatenate(mySource1, myLastLine1, start1 - 1);
    }
    if (myLastLine2 < start2) {
        text2 = concatenate(mySource2, myLastLine2, start2 - 1);
    }
    if (text1 != null || text2 != null) {
        myData.add(DiffFragment.unchanged(text1, text2));
    }
    myData.add(new DiffFragment(concatenate(mySource1, start1, end1), concatenate(mySource2, start2, end2)));
    myLastLine1 = end1 + 1;
    myLastLine2 = end2 + 1;
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment) DiffString(com.intellij.openapi.diff.impl.string.DiffString)

Example 17 with DiffFragment

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

the class FragmentStringConvertion method convert.

@Override
public String convert(Object obj) {
    Assert.assertNotNull(obj);
    DiffFragment fragment = (DiffFragment) obj;
    return String.valueOf(fragment.getText1()) + "->" + String.valueOf(fragment.getText2()) + "\n-----------";
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 18 with DiffFragment

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

the class UtilTest method testCutFirst.

public void testCutFirst() {
    prepareForFragments();
    CHECK.singleElement(Util.cutFirst(new DiffFragment[] { DiffFragment.unchanged("ab", "ac") }), DiffFragment.unchanged("b", "c"));
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(null, "c") }, Util.cutFirst(new DiffFragment[] { new DiffFragment(null, "b"), new DiffFragment(null, "c"), new DiffFragment("a", null) }));
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(null, "b"), new DiffFragment(null, "d") }, Util.cutFirst(new DiffFragment[] { new DiffFragment(null, "ab"), new DiffFragment("c", "d") }));
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 19 with DiffFragment

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

the class UtilTest method testUniteFormattingOnly.

public void testUniteFormattingOnly() {
    prepareForFragments();
    DiffFragment[] first = new DiffFragment[] { DiffFragment.unchanged("123", "abc") };
    DiffFragment[] last = new DiffFragment[] { new DiffFragment("qqq", "qqq") };
    DiffFragment inline1 = new DiffFragment(" ", "  ");
    DiffFragment inline2 = DiffFragment.unchanged("xyz", "cba");
    DiffFragment inline3 = new DiffFragment("  ", " ");
    DiffFragment inline4 = DiffFragment.unchanged("098", "890");
    DiffFragment[][] lines = new DiffFragment[][] { first, new DiffFragment[] { inline1, inline2 }, new DiffFragment[] { inline3, inline4 }, last };
    lines = Util.uniteFormattingOnly(lines);
    CHECK.compareAll(new DiffFragment[][] { first, new DiffFragment[] { inline1, inline2, inline3, inline4 }, last }, lines);
}
Also used : DiffFragment(com.intellij.openapi.diff.ex.DiffFragment)

Example 20 with DiffFragment

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

the class UtilTest method testCutFirst3.

public void testCutFirst3() {
    prepareForFragments();
    CHECK.compareAll(new DiffFragment[] { new DiffFragment(null, ", ?"), new DiffFragment(")\");", ")\");") }, Util.cutFirst(new DiffFragment[] { new DiffFragment(null, "?, "), new DiffFragment("?)\");", "?)\");") }));
}
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