Search in sources :

Example 1 with IgnorePolicy

use of com.intellij.diff.tools.util.base.IgnorePolicy in project intellij-community by JetBrains.

the class TwosideTextDiffProviderBase method compare.

@Nullable
@Override
public List<LineFragment> compare(@NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull ProgressIndicator indicator) {
    IgnorePolicy ignorePolicy = getIgnorePolicy();
    HighlightPolicy highlightPolicy = getHighlightPolicy();
    if (!highlightPolicy.isShouldCompare())
        return null;
    ComparisonPolicy policy = ignorePolicy.getComparisonPolicy();
    boolean innerFragments = highlightPolicy.isFineFragments();
    boolean squashFragments = highlightPolicy.isShouldSquash();
    boolean trimFragments = ignorePolicy.isShouldTrimChunks();
    indicator.checkCanceled();
    List<LineFragment> fragments = doCompare(text1, text2, ignorePolicy, innerFragments, indicator);
    indicator.checkCanceled();
    return ComparisonManager.getInstance().processBlocks(fragments, text1, text2, policy, squashFragments, trimFragments);
}
Also used : IgnorePolicy(com.intellij.diff.tools.util.base.IgnorePolicy) LineFragment(com.intellij.diff.fragments.LineFragment) ComparisonPolicy(com.intellij.diff.comparison.ComparisonPolicy) HighlightPolicy(com.intellij.diff.tools.util.base.HighlightPolicy) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with IgnorePolicy

use of com.intellij.diff.tools.util.base.IgnorePolicy 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)2 HighlightPolicy (com.intellij.diff.tools.util.base.HighlightPolicy)2 IgnorePolicy (com.intellij.diff.tools.util.base.IgnorePolicy)2 LineFragment (com.intellij.diff.fragments.LineFragment)1 MergeLineFragment (com.intellij.diff.fragments.MergeLineFragment)1 MergeConflictType (com.intellij.diff.util.MergeConflictType)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1