Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2010-10-21 05:57:35 -0400
committerTomasz Zarna2010-10-21 05:57:35 -0400
commit317db243865fb97c7fdbdad863f8b55f2c1674bf (patch)
treee8bbf4d21acfb9948b4007aa1227d263692217cb
parent732036b9daf5da38f2bc8dd4fd85a5c99af76a16 (diff)
downloadeclipse.platform.team-R3_6_1_maintenance_patches.tar.gz
eclipse.platform.team-R3_6_1_maintenance_patches.tar.xz
eclipse.platform.team-R3_6_1_maintenance_patches.zip
bug 325946: [backport] Provide a way to disable capping in the comparison algorithmR36x_v20101021-1117R3_6_1_maintenance_patches
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java18
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java6
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java11
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java5
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java37
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties1
6 files changed, 66 insertions, 12 deletions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java
index 4f8aa60a8..fb52f0184 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/ComparePlugin.java
@@ -25,7 +25,9 @@ public class ComparePlugin extends Plugin {
// The shared instance
private static ComparePlugin plugin;
-
+
+ private boolean cappingDisabled;
+
/**
* The constructor
*/
@@ -53,7 +55,7 @@ public class ComparePlugin extends Plugin {
/**
* Returns the shared instance
- *
+ *
* @return the shared instance
*/
public static ComparePlugin getDefault() {
@@ -61,11 +63,19 @@ public class ComparePlugin extends Plugin {
}
public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, PLUGIN_ID, 0, Messages.Activator_1, e));
+ log(new Status(IStatus.ERROR, PLUGIN_ID, 0, Messages.Activator_1, e));
}
-
+
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
+ public void setCappingDisabled(boolean disable) {
+ this.cappingDisabled = disable;
+ }
+
+ public boolean isCappingDisabled() {
+ return this.cappingDisabled;
+ }
+
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java
index 26b40dde5..e458e233e 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare.core/src/org/eclipse/compare/internal/core/LCS.java
@@ -52,7 +52,7 @@ public abstract class LCS {
}
this.max_differences = (length1 + length2 + 1) / 2; // ceil((N+M)/2)
- if ((double) length1 * (double) length2 > TOO_LONG) {
+ if (!isCappingDisabled() && (double) length1 * (double) length2 > TOO_LONG) {
// limit complexity to D^POW_LIMIT for long sequences
this.max_differences = (int) Math.pow(this.max_differences, POW_LIMIT - 1.0);
}
@@ -94,6 +94,10 @@ public abstract class LCS {
}
+ private boolean isCappingDisabled() {
+ return ComparePlugin.getDefault().isCappingDisabled();
+ }
+
/**
* The recursive helper function for Myers' LCS. Computes the LCS of
* l1[bottoml1 .. topl1] and l2[bottoml2 .. topl2] fills in the appropriate
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
index 11a62dac6..d9d18b0eb 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ComparePreferencePage.java
@@ -20,6 +20,7 @@ import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.IEncodedStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.internal.core.ComparePlugin;
import org.eclipse.compare.structuremergeviewer.DiffNode;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.jface.dialogs.Dialog;
@@ -92,6 +93,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
public static final String USE_SINGLE_LINE= PREFIX + "UseSingleLine"; //$NON-NLS-1$
public static final String HIGHLIGHT_TOKEN_CHANGES= PREFIX + "HighlightTokenChanges"; //$NON-NLS-1$
//public static final String USE_RESOLVE_UI= PREFIX + "UseResolveUI"; //$NON-NLS-1$
+ public static final String CAPPING_DISABLED= PREFIX + "CappingDisable"; //$NON-NLS-1$
public static final String PATH_FILTER= PREFIX + "PathFilter"; //$NON-NLS-1$
public static final String ADDED_LINES_REGEX= PREFIX + "AddedLinesRegex"; //$NON-NLS-1$
public static final String REMOVED_LINES_REGEX= PREFIX + "RemovedLinesRegex"; //$NON-NLS-1$
@@ -122,6 +124,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_SINGLE_LINE),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, HIGHLIGHT_TOKEN_CHANGES),
//new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, USE_RESOLVE_UI),
+ new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CAPPING_DISABLED),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PATH_FILTER),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION),
new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL),
@@ -143,6 +146,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
store.setDefault(USE_SINGLE_LINE, true);
store.setDefault(HIGHLIGHT_TOKEN_CHANGES, true);
//store.setDefault(USE_RESOLVE_UI, false);
+ store.setDefault(CAPPING_DISABLED, false);
store.setDefault(PATH_FILTER, ""); //$NON-NLS-1$
store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION, ICompareUIConstants.PREF_VALUE_PROMPT);
store.setDefault(ICompareUIConstants.PREF_NAVIGATION_END_ACTION_LOCAL, ICompareUIConstants.PREF_VALUE_LOOP);
@@ -183,8 +187,12 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
fOverlayStore.setValue(ADDED_LINES_REGEX, addedLinesRegex.getText());
fOverlayStore.setValue(REMOVED_LINES_REGEX, removedLinesRegex.getText());
- editor.store();
+ editor.store();
fOverlayStore.propagate();
+
+ ComparePlugin.getDefault().setCappingDisabled(
+ getPreferenceStore().getBoolean(
+ ComparePreferencePage.CAPPING_DISABLED));
return true;
}
@@ -343,6 +351,7 @@ public class ComparePreferencePage extends PreferencePage implements IWorkbenchP
addCheckBox(composite, "ComparePreferencePage.useSingleLine.label", USE_SINGLE_LINE, 0); //$NON-NLS-1$
addCheckBox(composite, "ComparePreferencePage.highlightTokenChanges.label", HIGHLIGHT_TOKEN_CHANGES, 0); //$NON-NLS-1$
//addCheckBox(composite, "ComparePreferencePage.useResolveUI.label", USE_RESOLVE_UI, 0); //$NON-NLS-1$
+ addCheckBox(composite, "ComparePreferencePage.disableCapping.label", CAPPING_DISABLED, 0); //$NON-NLS-1$
Composite radioGroup = new Composite(composite, SWT.NULL);
radioGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index b3d058c9a..4e32e94e9 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -32,6 +32,7 @@ import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.IStreamMerger;
import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.internal.core.ComparePlugin;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.IStructureCreator;
import org.eclipse.compare.structuremergeviewer.StructureDiffViewer;
@@ -256,6 +257,10 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
public void start(BundleContext context) throws Exception {
super.start(context);
+
+ ComparePlugin.getDefault().setCappingDisabled(
+ getPreferenceStore().getBoolean(
+ ComparePreferencePage.CAPPING_DISABLED));
}
public void stop(BundleContext context) throws Exception {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
index 1dc8bb847..abbd29455 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/DocumentMerger.java
@@ -11,17 +11,36 @@
package org.eclipse.compare.internal.merge;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.contentmergeviewer.ITokenComparator;
-import org.eclipse.compare.internal.*;
+import org.eclipse.compare.internal.CompareContentViewerSwitchingPane;
+import org.eclipse.compare.internal.CompareMessages;
+import org.eclipse.compare.internal.ComparePreferencePage;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.DocLineComparator;
+import org.eclipse.compare.internal.MergeViewerContentProvider;
+import org.eclipse.compare.internal.Utilities;
import org.eclipse.compare.internal.core.LCS;
-import org.eclipse.compare.rangedifferencer.*;
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.*;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.BadPositionCategoryException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextUtilities;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.PlatformUI;
@@ -412,7 +431,7 @@ public class DocumentMerger {
}
}*/
}
-
+
final Object[] result= new Object[1];
final DocLineComparator sa= sancestor, sl= sleft, sr= sright;
IRunnableWithProgress runnable= new IRunnableWithProgress() {
@@ -532,6 +551,8 @@ public class DocumentMerger {
private boolean isCapped(DocLineComparator ancestor,
DocLineComparator left, DocLineComparator right) {
+ if (isCappingDisabled())
+ return false;
int aLength = ancestor == null? 0 : ancestor.getRangeCount();
int lLength = left.getRangeCount();
int rLength = right.getRangeCount();
@@ -648,6 +669,10 @@ public class DocumentMerger {
return Utilities.getBoolean(getCompareConfiguration(), CompareConfiguration.IGNORE_WHITESPACE, false);
}
+ private boolean isCappingDisabled() {
+ return CompareUIPlugin.getDefault().getPreferenceStore().getBoolean(ComparePreferencePage.CAPPING_DISABLED);
+ }
+
private IDocument getDocument(char contributor) {
return fInput.getDocument(contributor);
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
index c8e2865c7..a5fb23fb3 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -130,6 +130,7 @@ ComparePreferencePage.showPseudoConflicts.label= Show &pseudo conflicts
ComparePreferencePage.synchronizeScrolling.label= Synchronize &scrolling between panes in compare viewers
ComparePreferencePage.useSingleLine.label= Connect &ranges with single line
ComparePreferencePage.highlightTokenChanges.label=&Highlight individual changes
+ComparePreferencePage.disableCapping.label=Disable &capping when comparing large documents
ComparePreferencePage.preview.label= Previe&w:
ComparePreferencePage.ancestor.label= Common Ancestor

Back to the top