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;
}
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-----------";
}
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") }));
}
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);
}
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("?)\");", "?)\");") }));
}
Aggregations