Search in sources :

Example 11 with FairDiffIterable

use of com.intellij.diff.comparison.iterables.FairDiffIterable in project intellij-community by JetBrains.

the class ByChar method compareIgnoreWhitespaces.

@NotNull
public static DiffIterable compareIgnoreWhitespaces(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ProgressIndicator indicator) {
    indicator.checkCanceled();
    CharOffsets chars1 = getNonSpaceChars(text1);
    CharOffsets chars2 = getNonSpaceChars(text2);
    FairDiffIterable changes = diff(chars1.characters, chars2.characters, indicator);
    return matchAdjustmentSpacesIW(chars1, chars2, text1, text2, changes);
}
Also used : FairDiffIterable(com.intellij.diff.comparison.iterables.FairDiffIterable) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with FairDiffIterable

use of com.intellij.diff.comparison.iterables.FairDiffIterable in project intellij-community by JetBrains.

the class ByWord method comparePunctuation2Side.

/*
   * Compare one char sequence with two others (as if they were single sequence)
   *
   * Return two DiffIterable: (0, len1) - (0, len21) and (0, len1) - (0, len22)
   */
@NotNull
private static Couple<FairDiffIterable> comparePunctuation2Side(@NotNull CharSequence text1, @NotNull CharSequence text21, @NotNull CharSequence text22, @NotNull ProgressIndicator indicator) {
    CharSequence text2 = new MergingCharSequence(text21, text22);
    FairDiffIterable changes = ByChar.comparePunctuation(text1, text2, indicator);
    Couple<List<Range>> ranges = splitIterable2Side(changes, text21.length());
    FairDiffIterable iterable1 = fair(createUnchanged(ranges.first, text1.length(), text21.length()));
    FairDiffIterable iterable2 = fair(createUnchanged(ranges.second, text1.length(), text22.length()));
    return Couple.of(iterable1, iterable2);
}
Also used : MergingCharSequence(com.intellij.util.text.MergingCharSequence) MergingCharSequence(com.intellij.util.text.MergingCharSequence) FairDiffIterable(com.intellij.diff.comparison.iterables.FairDiffIterable) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with FairDiffIterable

use of com.intellij.diff.comparison.iterables.FairDiffIterable in project intellij-community by JetBrains.

the class ByWord method compare.

@NotNull
public static List<DiffFragment> compare(@NotNull CharSequence text1, @NotNull List<InlineChunk> words1, @NotNull CharSequence text2, @NotNull List<InlineChunk> words2, @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) {
    FairDiffIterable wordChanges = diff(words1, words2, indicator);
    wordChanges = optimizeWordChunks(text1, text2, words1, words2, wordChanges, indicator);
    FairDiffIterable delimitersIterable = matchAdjustmentDelimiters(text1, text2, words1, words2, wordChanges, indicator);
    DiffIterable iterable = matchAdjustmentWhitespaces(text1, text2, delimitersIterable, policy, indicator);
    return convertIntoDiffFragments(iterable);
}
Also used : FairDiffIterable(com.intellij.diff.comparison.iterables.FairDiffIterable) FairDiffIterable(com.intellij.diff.comparison.iterables.FairDiffIterable) DiffIterable(com.intellij.diff.comparison.iterables.DiffIterable) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with FairDiffIterable

use of com.intellij.diff.comparison.iterables.FairDiffIterable in project intellij-community by JetBrains.

the class ByWord method compare.

@NotNull
public static List<MergeWordFragment> compare(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull CharSequence text3, @NotNull ComparisonPolicy policy, @NotNull ProgressIndicator indicator) {
    indicator.checkCanceled();
    List<InlineChunk> words1 = getInlineChunks(text1);
    List<InlineChunk> words2 = getInlineChunks(text2);
    List<InlineChunk> words3 = getInlineChunks(text3);
    FairDiffIterable wordChanges1 = diff(words2, words1, indicator);
    wordChanges1 = optimizeWordChunks(text2, text1, words2, words1, wordChanges1, indicator);
    FairDiffIterable iterable1 = matchAdjustmentDelimiters(text2, text1, words2, words1, wordChanges1, indicator);
    FairDiffIterable wordChanges2 = diff(words2, words3, indicator);
    wordChanges2 = optimizeWordChunks(text2, text3, words2, words3, wordChanges2, indicator);
    FairDiffIterable iterable2 = matchAdjustmentDelimiters(text2, text3, words2, words3, wordChanges2, indicator);
    List<MergeRange> wordConflicts = ComparisonMergeUtil.buildFair(iterable1, iterable2, indicator);
    List<MergeRange> result = matchAdjustmentWhitespaces(text1, text2, text3, wordConflicts, policy, indicator);
    return convertIntoMergeWordFragments(result);
}
Also used : FairDiffIterable(com.intellij.diff.comparison.iterables.FairDiffIterable) MergeRange(com.intellij.diff.util.MergeRange) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FairDiffIterable (com.intellij.diff.comparison.iterables.FairDiffIterable)14 NotNull (org.jetbrains.annotations.NotNull)14 ArrayList (java.util.ArrayList)4 DiffIterable (com.intellij.diff.comparison.iterables.DiffIterable)2 MergeRange (com.intellij.diff.util.MergeRange)2 Range (com.intellij.diff.util.Range)2 MergingCharSequence (com.intellij.util.text.MergingCharSequence)2 List (java.util.List)2 DiffTooBigException (com.intellij.diff.comparison.DiffTooBigException)1 WordBlock (com.intellij.diff.comparison.LineFragmentSplitter.WordBlock)1 DiffFragment (com.intellij.diff.fragments.DiffFragment)1 DiffUtil (com.intellij.diff.util.DiffUtil)1 InnerRange (com.intellij.openapi.vcs.ex.Range.InnerRange)1 TIntArrayList (gnu.trove.TIntArrayList)1 BitSet (java.util.BitSet)1