Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgoubet2019-09-04 05:18:59 -0400
committerlgoubet2019-09-04 05:18:59 -0400
commit057565817412dd193eac16a0c389be9c5474e727 (patch)
tree396107d8e6667b4a53aa510058b7d385ff52f13a
parent6b7ff72076920b9913bcbb6dceded85830ef25a4 (diff)
downloadorg.eclipse.emf.compare-057565817412dd193eac16a0c389be9c5474e727.tar.gz
org.eclipse.emf.compare-057565817412dd193eac16a0c389be9c5474e727.tar.xz
org.eclipse.emf.compare-057565817412dd193eac16a0c389be9c5474e727.zip
Make sure the UI won't try to compute the LCS for huge lists
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/property/PropertyDescriptorItem.java5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/provider/TreeMergeViewerItemContentProvider.java16
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/EMFCompareConstants.java11
-rw-r--r--plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/accessor/impl/ManyStructuralFeatureAccessorImpl.java4
4 files changed, 20 insertions, 16 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/property/PropertyDescriptorItem.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/property/PropertyDescriptorItem.java
index d66cf7479..9a397a597 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/property/PropertyDescriptorItem.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/property/PropertyDescriptorItem.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.compare.DifferenceSource;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
+import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
import org.eclipse.emf.compare.rcp.ui.internal.util.MergeViewerUtil;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.IMergeViewerItem;
@@ -119,7 +120,7 @@ class PropertyDescriptorItem extends PropertyItem {
getSide()));
}
- if (haveDiffs()) {
+ if (haveDiffs() && listValue.size() < EMFCompareConstants.LIST_SIZE_INSERTION_POINT_THRESHOLD) {
createPlaceholders(propertyItems);
}
}
@@ -154,7 +155,7 @@ class PropertyDescriptorItem extends PropertyItem {
final int count = size(filter(subList, IMergeViewerItem.IS_INSERTION_POINT));
index = Math.min(insertionIndex + count, propertyItems.size());
} else {
- index = 0;
+ index = 0;
}
// Create the placeholder and insert it at the appropriate
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/provider/TreeMergeViewerItemContentProvider.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/provider/TreeMergeViewerItemContentProvider.java
index 2ddb4b231..ad9de1fbe 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/provider/TreeMergeViewerItemContentProvider.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/contentmergeviewer/tree/provider/TreeMergeViewerItemContentProvider.java
@@ -54,6 +54,7 @@ import org.eclipse.emf.compare.ResourceAttachmentChange;
import org.eclipse.emf.compare.graph.IGraphView;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
import org.eclipse.emf.compare.match.impl.NotLoadedFragmentMatch;
+import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.ResourceAttachmentChangeMergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.internal.util.MergeViewerUtil;
@@ -81,17 +82,6 @@ import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
public class TreeMergeViewerItemContentProvider implements IMergeViewerItemContentProvider {
/**
- * If the list on any one of the sides contains more elements than the given threshold, don't try and
- * compute the insertion index for differences merging. On the one hand, showing insertion points in lists
- * with so many elements wouldn't reallybe human readable, on the other hand, trying to compute insertion
- * indices for too large lists will easily result in OutOfMemoryErrors. For example, if the left and right
- * sides contain 60000 elements, we'll end up trying to instantiate an array with the following signature:
- * "int[60000][60000]" to compute the LCS (see DiffUtils). Such an array would cost 13GB of memory as a
- * conservative estimate.
- */
- private static final short LIST_SIZE_INSERTION_POINT_THRESHOLD = 10000;
-
- /**
* {@inheritDoc}
*/
public boolean canHandle(Object object) {
@@ -311,8 +301,8 @@ public class TreeMergeViewerItemContentProvider implements IMergeViewerItemConte
List<Object> ancestorContent = getChildrenFromContentProvider(
getSideValue(parent, MergeViewerSide.ANCESTOR), adapterFactory);
- if (sideContent.size() > LIST_SIZE_INSERTION_POINT_THRESHOLD
- && oppositeContent.size() > LIST_SIZE_INSERTION_POINT_THRESHOLD) {
+ if (sideContent.size() > EMFCompareConstants.LIST_SIZE_INSERTION_POINT_THRESHOLD
+ && oppositeContent.size() > EMFCompareConstants.LIST_SIZE_INSERTION_POINT_THRESHOLD) {
return new ArrayList<IMergeViewerItem>(values);
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/EMFCompareConstants.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/EMFCompareConstants.java
index 00f7338e9..f5546d535 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/EMFCompareConstants.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/EMFCompareConstants.java
@@ -27,4 +27,15 @@ public final class EMFCompareConstants {
public static final String NODE_TYPE__EMF_EOBJECT = "NODE_TYPE__EMF_EOBJECT"; //$NON-NLS-1$
+ /**
+ * If the list on any one of the sides we're trying to display in the UI contains more elements than the
+ * given threshold, don't try and compute the insertion index for differences merging. On the one hand,
+ * showing insertion points in lists with so many elements wouldn't really be human readable, on the other
+ * hand, trying to compute insertion indices for too large lists will easily result in OutOfMemoryErrors.
+ * For example, if the left and right sides contain 60000 elements, we'll end up trying to instantiate an
+ * array with the following signature: "int[60000][60000]" to compute the LCS (see DiffUtils). Such an
+ * array would cost 13GB of memory as a conservative estimate.
+ */
+ public static final short LIST_SIZE_INSERTION_POINT_THRESHOLD = 10000;
+
}
diff --git a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/accessor/impl/ManyStructuralFeatureAccessorImpl.java b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/accessor/impl/ManyStructuralFeatureAccessorImpl.java
index 09f6b65be..14b152327 100644
--- a/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/accessor/impl/ManyStructuralFeatureAccessorImpl.java
+++ b/plugins/org.eclipse.emf.compare.rcp.ui/src/org/eclipse/emf/compare/rcp/ui/internal/contentmergeviewer/accessor/impl/ManyStructuralFeatureAccessorImpl.java
@@ -33,6 +33,7 @@ import org.eclipse.emf.compare.FeatureMapChange;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
+import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
import org.eclipse.emf.compare.rcp.ui.internal.mergeviewer.item.impl.MergeViewerItem;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.IMergeViewer.MergeViewerSide;
import org.eclipse.emf.compare.rcp.ui.mergeviewer.item.IMergeViewerItem;
@@ -77,7 +78,8 @@ public class ManyStructuralFeatureAccessorImpl extends AbstractStructuralFeature
List<?> list = getFeatureValues(getSide());
ret = createMergeViewerItemFrom(list);
- if (getSide() != MergeViewerSide.ANCESTOR) {
+ if (getSide() != MergeViewerSide.ANCESTOR
+ && list.size() < EMFCompareConstants.LIST_SIZE_INSERTION_POINT_THRESHOLD) {
ret = createInsertionPoints(ret);
}

Back to the top