Search in sources :

Example 6 with LineFragment

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));
}
Also used : LineFragment(com.intellij.diff.fragments.LineFragment)

Example 7 with 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.
}
Also used : LineFragment(com.intellij.diff.fragments.LineFragment)

Example 8 with LineFragment

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);
}
Also used : LineFragment(com.intellij.diff.fragments.LineFragment)

Example 9 with LineFragment

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());
    }
}
Also used : LineFragment(com.intellij.diff.fragments.LineFragment) DiffTooBigException(com.intellij.diff.comparison.DiffTooBigException) Document(com.intellij.openapi.editor.Document) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) ObjectUtils.assertNotNull(com.intellij.util.ObjectUtils.assertNotNull)

Aggregations

LineFragment (com.intellij.diff.fragments.LineFragment)9 DiffTooBigException (com.intellij.diff.comparison.DiffTooBigException)3 DiffFragment (com.intellij.diff.fragments.DiffFragment)2 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)2 ComparisonManager (com.intellij.diff.comparison.ComparisonManager)1 ComparisonPolicy (com.intellij.diff.comparison.ComparisonPolicy)1 DocumentContent (com.intellij.diff.contents.DocumentContent)1 HighlightPolicy (com.intellij.diff.tools.util.base.HighlightPolicy)1 IgnorePolicy (com.intellij.diff.tools.util.base.IgnorePolicy)1 Document (com.intellij.openapi.editor.Document)1 DocumentEx (com.intellij.openapi.editor.ex.DocumentEx)1 EditorEx (com.intellij.openapi.editor.ex.EditorEx)1 EditorHighlighter (com.intellij.openapi.editor.highlighter.EditorHighlighter)1 FileType (com.intellij.openapi.fileTypes.FileType)1 TextRange (com.intellij.openapi.util.TextRange)1 ObjectUtils.assertNotNull (com.intellij.util.ObjectUtils.assertNotNull)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1