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);
}
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);
}
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);
}
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);
}
Aggregations