diff --git a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java index 0a4b1099f3de..40aa76fa3074 100644 --- a/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java +++ b/platform/diff-impl/src/com/intellij/diff/tools/simple/SimpleDiffViewer.java @@ -194,11 +194,11 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { StringUtil.equals(texts[0], texts[1]); if (lineFragments == null) { - return apply(createCompareData(null, isContentsEqual)); + return apply(null, isContentsEqual); } else { List changes = ContainerUtil.map(lineFragments, fragment -> new SimpleDiffChange(this, fragment)); - return apply(createCompareData(changes, isContentsEqual)); + return apply(changes, isContentsEqual); } } catch (DiffTooBigException e) { @@ -214,28 +214,23 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { } @NotNull - protected CompareData createCompareData(@Nullable List changes, - boolean isContentsEqual) { + protected Runnable apply(@Nullable List changes, + boolean isContentsEqual) { List nonSkipped = changes != null ? ContainerUtil.filter(changes, it -> !it.isSkipped()) : null; FoldingModelSupport.Data foldingState = myFoldingModel.createState(nonSkipped, getFoldingModelSettings()); - return new CompareData(changes, isContentsEqual, foldingState); - } - @NotNull - protected Runnable apply(@NotNull CompareData data) { return () -> { myFoldingModel.updateContext(myRequest, getFoldingModelSettings()); clearDiffPresentation(); - myIsContentsEqual = data.isContentsEqual(); - if (data.isContentsEqual()) { + myIsContentsEqual = isContentsEqual; + if (isContentsEqual) { boolean equalCharsets = TextDiffViewerUtil.areEqualCharsets(getContents()); boolean equalSeparators = TextDiffViewerUtil.areEqualLineSeparators(getContents()); myPanel.addNotification(DiffNotifications.createEqualContents(equalCharsets, equalSeparators)); } - List changes = data.getChanges(); if (changes != null) { for (int i = 0; i < changes.size(); i++) { SimpleDiffChange change = changes.get(i); @@ -246,7 +241,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { myDiffChanges.addAll(changes); } - myFoldingModel.install(data.getFoldingState(), myRequest, getFoldingModelSettings()); + myFoldingModel.install(foldingState, myRequest, getFoldingModelSettings()); myInitialScrollHelper.onRediff(); @@ -789,34 +784,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer { } } - private static class CompareData { - @Nullable private final List myChanges; - private final boolean myIsContentsEqual; - @Nullable private final FoldingModelSupport.Data myFoldingState; - - private CompareData(@Nullable List changes, - boolean isContentsEqual, - @Nullable FoldingModelSupport.Data state) { - myChanges = changes; - myIsContentsEqual = isContentsEqual; - myFoldingState = state; - } - - @Nullable - public List getChanges() { - return myChanges; - } - - public boolean isContentsEqual() { - return myIsContentsEqual; - } - - @Nullable - public FoldingModelSupport.Data getFoldingState() { - return myFoldingState; - } - } - public class ModifierProvider extends KeyboardModifierListener { public void init() { init(myPanel, SimpleDiffViewer.this); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java index 5743253d1281..f11941307ea7 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/diff/lst/SimpleLocalChangeListDiffViewer.java @@ -198,7 +198,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { } if (myTextDiffProvider.isHighlightingDisabled()) { - return apply(createCompareData(null, ranges.isEmpty())); + return apply(null, ranges.isEmpty()); } @@ -221,7 +221,7 @@ public class SimpleLocalChangeListDiffViewer extends SimpleDiffViewer { changes.addAll(ContainerUtil.map(rangeFragments, fragment -> new MySimpleDiffChange(fragment, isExcluded, isSkipped, localRange.getChangelistId(), isExcludedFromCommit))); } - return apply(createCompareData(changes, isContentsEqual)); + return apply(changes, isContentsEqual); } @Override