use of com.intellij.diff.fragments.LineFragment in project intellij-community by JetBrains.
the class UnifiedDiffViewer method appendChange.
@CalledWithWriteLock
public void appendChange(@NotNull UnifiedDiffChange change, @NotNull final Side sourceSide) {
Side outputSide = sourceSide.other();
Document document1 = getDocument(Side.LEFT);
Document document2 = getDocument(Side.RIGHT);
LineFragment lineFragment = change.getLineFragment();
if (sourceSide.getStartLine(lineFragment) == sourceSide.getEndLine(lineFragment))
return;
DiffUtil.applyModification(outputSide.select(document1, document2), outputSide.getEndLine(lineFragment), outputSide.getEndLine(lineFragment), sourceSide.select(document1, document2), sourceSide.getStartLine(lineFragment), sourceSide.getEndLine(lineFragment));
}
use of com.intellij.diff.fragments.LineFragment in project intellij-community by JetBrains.
the class UnifiedDiffViewer method replaceChange.
@CalledWithWriteLock
public void replaceChange(@NotNull UnifiedDiffChange change, @NotNull Side sourceSide) {
Side outputSide = sourceSide.other();
Document document1 = getDocument(Side.LEFT);
Document document2 = getDocument(Side.RIGHT);
LineFragment lineFragment = change.getLineFragment();
DiffUtil.applyModification(outputSide.select(document1, document2), outputSide.getStartLine(lineFragment), outputSide.getEndLine(lineFragment), sourceSide.select(document1, document2), sourceSide.getStartLine(lineFragment), sourceSide.getEndLine(lineFragment));
// no need to mark myStateIsOutOfDate - it will be made by DocumentListener
// TODO: we can apply change manually, without marking state out-of-date. But we'll have to schedule rediff anyway.
}
use of com.intellij.diff.fragments.LineFragment in project intellij-community by JetBrains.
the class UnifiedFragmentBuilder method exec.
public void exec() {
if (myFragments.isEmpty()) {
myEqual = true;
appendTextMaster(0, 0, getLineCount(myDocument1) - 1, getLineCount(myDocument2) - 1);
return;
}
for (LineFragment fragment : myFragments) {
processEquals(fragment.getStartLine1() - 1, fragment.getStartLine2() - 1);
processChanged(fragment);
}
processEquals(getLineCount(myDocument1) - 1, getLineCount(myDocument2) - 1);
}
use of com.intellij.diff.fragments.LineFragment in project intellij-community by JetBrains.
the class SimpleDiffViewer method performRediff.
@Override
@NotNull
protected Runnable performRediff(@NotNull final ProgressIndicator indicator) {
try {
indicator.checkCanceled();
final Document document1 = getContent1().getDocument();
final Document document2 = getContent2().getDocument();
CharSequence[] texts = ReadAction.compute(() -> {
return new CharSequence[] { document1.getImmutableCharSequence(), document2.getImmutableCharSequence() };
});
List<LineFragment> lineFragments = myTextDiffProvider.compare(texts[0], texts[1], indicator);
boolean isContentsEqual = (lineFragments == null || lineFragments.isEmpty()) && StringUtil.equals(texts[0], texts[1]);
return apply(new CompareData(lineFragments, isContentsEqual));
} catch (DiffTooBigException e) {
return applyNotification(DiffNotifications.createDiffTooBig());
} catch (ProcessCanceledException e) {
throw e;
} catch (Throwable e) {
LOG.error(e);
return applyNotification(DiffNotifications.createError());
}
}
Aggregations