Search in sources :

Example 1 with MergeConflictType

use of com.intellij.diff.util.MergeConflictType in project intellij-community by JetBrains.

the class SimpleThreesideTextDiffProvider method compare.

@NotNull
public List<FineMergeLineFragment> compare(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull CharSequence text3, @NotNull ProgressIndicator indicator) {
    IgnorePolicy ignorePolicy = getIgnorePolicy();
    HighlightPolicy highlightPolicy = getHighlightPolicy();
    ComparisonPolicy comparisonPolicy = ignorePolicy.getComparisonPolicy();
    List<CharSequence> sequences = ContainerUtil.list(text1, text2, text3);
    List<LineOffsets> lineOffsets = ContainerUtil.map(sequences, LineOffsets::create);
    indicator.checkCanceled();
    List<MergeLineFragment> lineFragments = ComparisonManager.getInstance().compareLines(text1, text2, text3, comparisonPolicy, indicator);
    indicator.checkCanceled();
    List<FineMergeLineFragment> result = new ArrayList<>(lineFragments.size());
    for (MergeLineFragment fragment : lineFragments) {
        MergeConflictType conflictType = DiffUtil.getLineMergeType(fragment, sequences, lineOffsets, comparisonPolicy);
        MergeInnerDifferences innerDifferences;
        if (highlightPolicy.isFineFragments()) {
            List<CharSequence> chunks = getChunks(fragment, sequences, lineOffsets, conflictType);
            innerDifferences = DiffUtil.compareThreesideInner(chunks, comparisonPolicy, indicator);
        } else {
            innerDifferences = null;
        }
        result.add(new FineMergeLineFragmentImpl(fragment, conflictType, innerDifferences));
    }
    return result;
}
Also used : MergeLineFragment(com.intellij.diff.fragments.MergeLineFragment) ComparisonPolicy(com.intellij.diff.comparison.ComparisonPolicy) ArrayList(java.util.ArrayList) MergeConflictType(com.intellij.diff.util.MergeConflictType) IgnorePolicy(com.intellij.diff.tools.util.base.IgnorePolicy) HighlightPolicy(com.intellij.diff.tools.util.base.HighlightPolicy) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ComparisonPolicy (com.intellij.diff.comparison.ComparisonPolicy)1 MergeLineFragment (com.intellij.diff.fragments.MergeLineFragment)1 HighlightPolicy (com.intellij.diff.tools.util.base.HighlightPolicy)1 IgnorePolicy (com.intellij.diff.tools.util.base.IgnorePolicy)1 MergeConflictType (com.intellij.diff.util.MergeConflictType)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1