use of com.intellij.openapi.diff.impl.string.DiffString in project intellij-community by JetBrains.
the class UniteSameType method covertSequentialOneSideToChange.
@NotNull
private static DiffFragment[] covertSequentialOneSideToChange(@NotNull DiffFragment[] fragments) {
if (fragments.length < 2)
return fragments;
DiffCorrection.FragmentsCollector collector = new DiffCorrection.FragmentsCollector();
// DiffFragment previous = fragments[0];
DiffFragment previous = null;
for (int i = 0; i < fragments.length; i++) {
DiffFragment fragment = fragments[i];
if (fragment.isOneSide()) {
if (previous == null)
previous = fragment;
else {
FragmentSide side = FragmentSide.chooseSide(fragment);
DiffString previousText = side.getText(previous);
if (previousText == null)
previousText = DiffString.EMPTY;
previous = side.createFragment(DiffString.concatenateNullable(previousText, side.getText(fragment)), side.getOtherText(previous), true);
}
} else {
if (previous != null)
collector.add(previous);
previous = null;
collector.add(fragment);
}
}
if (previous != null)
collector.add(previous);
return collector.toArray();
}
use of com.intellij.openapi.diff.impl.string.DiffString in project intellij-community by JetBrains.
the class DiffFragment method appendText1.
public void appendText1(@Nullable DiffString str) {
if (str == null)
return;
if (myText1 instanceof DiffStringBuilder) {
((DiffStringBuilder) myText1).append(str);
return;
}
if (myText1 instanceof DiffString) {
DiffString text1 = (DiffString) myText1;
if (DiffString.canInplaceConcatenate(text1, str)) {
myText1 = DiffString.concatenate(text1, str);
} else {
DiffStringBuilder builder = new DiffStringBuilder(text1.length() + str.length());
builder.append(text1);
builder.append(str);
myText1 = builder;
}
return;
}
throw new IllegalStateException("Bad DiffFragment: " + (myText1 != null ? myText1.getClass() : "null"));
}
use of com.intellij.openapi.diff.impl.string.DiffString in project intellij-community by JetBrains.
the class ComparisonPolicy method trimStrings.
@NotNull
protected Object[] trimStrings(@NotNull DiffString[] strings) {
Object[] result = new Object[strings.length];
for (int i = 0; i < strings.length; i++) {
DiffString string = strings[i];
result[i] = string.trim();
}
return result;
}
use of com.intellij.openapi.diff.impl.string.DiffString in project intellij-community by JetBrains.
the class DiffFragmentBuilder method delete.
private void delete(@NotNull TextRange range, int line) {
LOG.debug("DiffFragmentBuilder.delete(" + range + "," + line + ")");
DiffString text1 = null;
DiffString text2 = null;
int start = range.getStartOffset();
int end = range.getEndOffset();
if (myLastLine1 < start) {
text1 = concatenate(mySource1, myLastLine1, start - 1);
}
if (myLastLine2 <= line) {
text2 = concatenate(mySource2, myLastLine2, line);
}
if (text1 != null || text2 != null) {
myData.add(DiffFragment.unchanged(text1, text2));
}
myData.add(new DiffFragment(concatenate(mySource1, start, end), null));
myLastLine1 = end + 1;
myLastLine2 = line + 1;
}
use of com.intellij.openapi.diff.impl.string.DiffString in project intellij-community by JetBrains.
the class DiffFragmentBuilder method append.
private void append(int line, @NotNull TextRange range) {
LOG.debug("DiffFragmentBuilder.append(" + line + "," + range + "), modified:");
DiffString text1 = null;
DiffString text2 = null;
int start = range.getStartOffset();
int end = range.getEndOffset();
if (myLastLine1 <= line) {
text1 = concatenate(mySource1, myLastLine1, line);
}
if (myLastLine2 < start) {
text2 = concatenate(mySource2, myLastLine2, start - 1);
}
if (text1 != null || text2 != null) {
myData.add(DiffFragment.unchanged(text1, text2));
}
myData.add(new DiffFragment(null, concatenate(mySource2, start, end)));
myLastLine1 = line + 1;
myLastLine2 = end + 1;
}
Aggregations