Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Weinand2004-04-18 17:20:48 +0000
committerAndre Weinand2004-04-18 17:20:48 +0000
commitdfaea77b815c7e37741a050baf9eef2be8289628 (patch)
tree7ed0d1657b266ff9975744c456646597503d73d0
parent830ada75ca822c67d26d54337576e678a0aa639a (diff)
downloadeclipse.platform.team-dfaea77b815c7e37741a050baf9eef2be8289628.tar.gz
eclipse.platform.team-dfaea77b815c7e37741a050baf9eef2be8289628.tar.xz
eclipse.platform.team-dfaea77b815c7e37741a050baf9eef2be8289628.zip
first cut of #54091
-rw-r--r--bundles/org.eclipse.compare/buildnotes_compare.html8
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java4
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java70
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java89
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java33
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java55
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java57
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java68
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java32
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties15
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java87
-rw-r--r--bundles/org.eclipse.compare/plugin.properties1
-rw-r--r--bundles/org.eclipse.compare/plugin.xml13
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html8
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java70
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java89
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java33
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java55
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java57
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java68
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java32
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties15
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java87
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties1
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml13
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd7
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd126
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd4
-rw-r--r--bundles/org.eclipse.compare/schema/contentMergeViewers.exsd4
-rw-r--r--bundles/org.eclipse.compare/schema/contentViewers.exsd7
-rw-r--r--bundles/org.eclipse.compare/schema/streamMergers.exsd126
-rw-r--r--bundles/org.eclipse.compare/schema/structureCreators.exsd4
-rw-r--r--bundles/org.eclipse.compare/schema/structureMergeViewers.exsd4
-rw-r--r--tests/org.eclipse.compare.tests/.classpath2
-rw-r--r--tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java1
-rw-r--r--tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/StreamMergerTest.java148
-rw-r--r--tests/org.eclipse.compare.tests/plugin.xml1
40 files changed, 1355 insertions, 151 deletions
diff --git a/bundles/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/buildnotes_compare.html
index 451835fcd..87f26c976 100644
--- a/bundles/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/buildnotes_compare.html
@@ -12,6 +12,14 @@
<h1>
Eclipse Platform Build Notes<br>
Compare</h1>
+Eclipse Build Input April 20th 2004
+
+<h2>
+Problem reports fixed</h2>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=54091">#54091</a>: Allow headless diff and merge<br>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse Build Input April 13th 2004
<h2>
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 2eb990a18..09f477f55 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -274,7 +274,7 @@ public class EditionSelectionDialog extends ResizableDialog {
IStructureCreator structureCreator= null;
if (ppath != null) {
String type= target.getType();
- IStructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
+ StructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
if (scd != null)
structureCreator= scd.createStructureCreator();
}
@@ -345,7 +345,7 @@ public class EditionSelectionDialog extends ResizableDialog {
IStructureCreator structureCreator= null;
if (ppath != null) {
String type= target.getType();
- IStructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
+ StructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
if (scd != null)
structureCreator= scd.createStructureCreator();
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java
new file mode 100644
index 000000000..49414b1b0
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This interface defines a single operation for performing a three-way merge on three
+ * input streams. The merged result is written to an output stream.
+ * <p>
+ * Clients must implement this interface when contributing new mergers to the
+ * <code>org.eclipse.compare.streamMergers</code> extension point.
+ * </p>
+ *
+ * @see org.eclipse.compare.internal.merge.TextMerger
+ *
+ * @since 3.0
+ */
+public interface IStreamMerger {
+
+ /**
+ * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>)
+ */
+ public static final int OK= IStatus.OK;
+
+ /**
+ * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>)
+ */
+ public static final int CONFLICT= 1;
+
+ /**
+ * Status code describing an internal error (value <code>2</code>)
+ */
+ public static final int INTERNAL_ERROR= 2;
+
+ /**
+ * Performs a merge operation on the given input streams and writes the merge result to the output stream.
+ * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>.
+ * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>.
+ * For text oriented mergers the encoding for the input and output streams is honored.
+ *
+ * @param output the byte stream to which the merge result is written; the merger will not close the stream
+ * @param outputEncoding the encoding to use when writing to the output stream
+ * @param ancestor the byte stream from which the common ancestor is read
+ * @param ancestorEncoding the encoding of the ancestor input byte stream
+ * @param target the byte stream containing the target of the merge
+ * @param targetEncoding the encoding of the target input byte stream
+ * @param other the byte stream containing the target of the merge
+ * @param otherEncoding the encoding of the other input byte stream
+ * @param monitor reports progress of the merge operation
+ * @return returns an ISta
+ */
+ IStatus merge(OutputStream output, String outputEncoding,
+ InputStream ancestor, String ancestorEncoding,
+ InputStream target, String targetEncoding,
+ InputStream other, String otherEncoding,
+ IProgressMonitor monitor);
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
index d5e95ee70..ba585496e 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareUIPlugin.java
@@ -70,6 +70,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$
+ private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$
private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$
private static final String STRUCTURE_MERGEVIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$
private static final String CONTENT_MERGEVIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$
@@ -86,6 +87,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
/** Maps ImageDescriptors to Images */
private static Map fgImages2= new Hashtable(10);
+ private static Map fgStreamMergers= new Hashtable(10);
private static Map fgStructureCreators= new Hashtable(10);
private static Map fgStructureViewerDescriptors= new Hashtable(10);
private static Map fgStructureViewerAliases= new Hashtable(10);
@@ -134,56 +136,55 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
/**
- * Registers all structure creators, content merge viewers, and structure merge viewers
+ * Registers all stream mergers, structure creators, content merge viewers, and structure merge viewers
* that are found in the XML plugin files.
*/
private void registerExtensions() {
IPluginRegistry registry= Platform.getPluginRegistry();
+ // collect all IStreamMergers
+ IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STREAM_MERGER_EXTENSION_POINT);
+ for (int i= 0; i < elements.length; i++) {
+ StreamMergerDescriptor desc= new StreamMergerDescriptor(elements[i]);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStreamMerger(extensions, desc);
+ }
+
// collect all IStructureCreators
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT);
+ elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
- final IConfigurationElement conf= elements[i];
- String extensions= conf.getAttribute(EXTENSIONS_ATTRIBUTE);
- registerStructureCreator(extensions,
- new IStructureCreatorDescriptor() {
- public IStructureCreator createStructureCreator() {
- try {
- return (IStructureCreator) conf.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException ex) {
- log(ex.getStatus());
- }
- return null;
- }
- }
- );
+ StructureCreatorDescriptor desc= new StructureCreatorDescriptor(elements[i]);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStructureCreator(extensions, desc);
}
// collect all viewers which define the structure mergeviewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGEVIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerStructureViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStructureViewerDescriptor(extensions, desc);
}
// collect all viewers which define the content mergeviewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGEVIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerContentMergeViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerContentMergeViewerDescriptor(extensions, desc);
}
// collect all viewers which define the content viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerContentViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerContentViewerDescriptor(extensions, desc);
}
}
@@ -518,7 +519,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
* @param types one or more types separated by commas and whitespace
* @param descriptor the descriptor to register
*/
- public static void registerStructureCreator(String types, IStructureCreatorDescriptor descriptor) {
+ public static void registerStructureCreator(String types, StructureCreatorDescriptor descriptor) {
if (types != null) {
StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
while (tokenizer.hasMoreElements()) {
@@ -535,8 +536,8 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
* @return a descriptor for the given type, or <code>null</code> if no
* descriptor has been registered
*/
- public static IStructureCreatorDescriptor getStructureCreator(String type) {
- return (IStructureCreatorDescriptor) fgStructureCreators.get(normalizeCase(type));
+ public static StructureCreatorDescriptor getStructureCreator(String type) {
+ return (StructureCreatorDescriptor) fgStructureCreators.get(normalizeCase(type));
}
/**
@@ -580,7 +581,35 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fgContentViewerDescriptors.put(normalizeCase(extension), descriptor);
}
}
-
+
+ /**
+ * Registers the given stream merger descriptor for one or more types.
+ *
+ * @param types one or more types separated by commas and whitespace
+ * @param descriptor the descriptor to register
+ */
+ public static void registerStreamMerger(String types, StreamMergerDescriptor descriptor) {
+ StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreElements()) {
+ String extension= tokenizer.nextToken().trim();
+ fgStreamMergers.put(normalizeCase(extension), descriptor);
+ }
+ }
+
+ /**
+ * Returns a stream merger for the given type.
+ *
+ * @param type the type for which to find a stream merger
+ * @return a stream merger for the given type, or <code>null</code> if no
+ * stream merger has been registered
+ */
+ public static IStreamMerger createStreamMerger(String type) {
+ StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fgStreamMergers.get(type);
+ if (descriptor != null)
+ return descriptor.createStreamMerger();
+ return null;
+ }
+
/**
* Returns a structure compare viewer based on an old viewer and an input object.
* If the old viewer is suitable for showing the input, the old viewer
@@ -616,7 +645,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
if (vd != null)
return vd.createViewer(oldViewer, parent, configuration);
- IStructureCreatorDescriptor scc= getStructureCreator(type);
+ StructureCreatorDescriptor scc= getStructureCreator(type);
if (scc != null) {
IStructureCreator sc= scc.createStructureCreator();
if (sc != null) {
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java
deleted file mode 100644
index f5a845e80..000000000
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
-
-/**
- * A factory object for creating <code>IStructureCreator</code>s from a descriptor.
- * <p>
- * It is used when registering <code>IStructureCreator</code> for types
- * in <code>CompareUIPlugin.registerStructureCreator</code>.
- * </p>
- *
- * @see IStructureCreator
- * @see CompareUIPlugin
- */
-public interface IStructureCreatorDescriptor {
-
- /**
- * Creates a new structure creator.
- *
- * @return a newly created structure creator
- */
- IStructureCreator createStructureCreator();
-}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
new file mode 100644
index 000000000..bebd4f177
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.compare.IStreamMerger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * A factory proxy for creating a StructureCreator.
+ */
+class StreamMergerDescriptor {
+
+ private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+
+ private IConfigurationElement fElement;
+
+ /**
+ * Creates a new sorter node with the given configuration element.
+ */
+ public StreamMergerDescriptor(IConfigurationElement element) {
+ fElement= element;
+ }
+
+ /**
+ * Creates a new stream merger from this node.
+ */
+ public IStreamMerger createStreamMerger() {
+ try {
+ return (IStreamMerger)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ } catch (CoreException ex) {
+ //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ } catch (ClassCastException ex) {
+ //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Returns the streammergers's extensions.
+ */
+ public String getExtension() {
+ return fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java
new file mode 100644
index 000000000..8d0bc78ad
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+import org.eclipse.compare.structuremergeviewer.IStructureCreator;
+
+/**
+ * A factory proxy for creating a StructureCreator.
+ */
+public class StructureCreatorDescriptor {
+
+ private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+
+ private IConfigurationElement fElement;
+
+ /**
+ * Creates a new sorter node with the given configuration element.
+ */
+ public StructureCreatorDescriptor(IConfigurationElement element) {
+ fElement= element;
+ }
+
+ /**
+ * Creates a new sorter from this node.
+ */
+ public IStructureCreator createStructureCreator() {
+ try {
+ return (IStructureCreator)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ } catch (CoreException ex) {
+ CompareUIPlugin.log(ex.getStatus());
+ //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ } catch (ClassCastException ex) {
+ //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Returns the structure creator's extensions.
+ */
+ public String getExtension() {
+ return fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
new file mode 100644
index 000000000..6cda1f25e
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal.merge;
+
+import java.io.*;
+import java.util.ArrayList;
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+
+/**
+ * This implementation of IRangeComparator breaks an input stream into lines.
+ */
+class LineComparator implements IRangeComparator {
+
+ private String[] fLines;
+
+ public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException {
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding));
+ String line;
+ ArrayList ar = new ArrayList();
+ try {
+ while ((line = br.readLine()) != null)
+ ar.add(line);
+ } catch (IOException e) {
+ }
+ try {
+ is.close();
+ } catch (IOException e1) {
+ }
+ fLines = (String[]) ar.toArray(new String[ar.size()]);
+ }
+
+ String getLine(int ix) {
+ return fLines[ix];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
+ */
+ public int getRangeCount() {
+ return fLines.length;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
+ */
+ public boolean rangesEqual(int thisIndex, IRangeComparator other,
+ int otherIndex) {
+ String s1 = fLines[thisIndex];
+ String s2 = ((LineComparator) other).fLines[otherIndex];
+ return s1.equals(s2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
+ */
+ public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java
new file mode 100644
index 000000000..e72825d2a
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal.merge;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class MergeMessages {
+
+ private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.merge.MergeMessages";//$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ private MergeMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties
new file mode 100644
index 000000000..8b55acb6c
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2004 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+TextAutoMerge.inputEncodingError= Unsupported encoding for input streams
+TextAutoMerge.outputEncodingError= Unsupported encoding for output streams
+TextAutoMerge.outputIOError= IO error on writing
+TextAutoMerge.conflict= Conflict: cannot auto merge \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java
new file mode 100644
index 000000000..93caa32bf
--- /dev/null
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java
@@ -0,0 +1,87 @@
+package org.eclipse.compare.internal.merge;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.compare.*;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A simple merger for streams containing text lines.
+ */
+public class TextMerger implements IStreamMerger {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.compare.internal.merge.IAutoMerger#automerge(java.io.OutputStream,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus merge(OutputStream output, String outputEncoding,
+ InputStream ancestor, String ancestorEncoding,
+ InputStream target, String targetEncoding,
+ InputStream other, String otherEncoding,
+ IProgressMonitor monitor) {
+
+ LineComparator a, t, o;
+
+ try {
+ a= new LineComparator(ancestor, ancestorEncoding);
+ t= new LineComparator(target, targetEncoding);
+ o= new LineComparator(other, otherEncoding);
+ } catch (UnsupportedEncodingException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.inputEncodingError"), e); //$NON-NLS-1$
+ }
+
+ try {
+ char lineSeparator= '\n';
+
+ RangeDifference[] diffs = RangeDifferencer.findRanges(monitor, a, t, o);
+
+ for (int i = 0; i < diffs.length; i++) {
+ RangeDifference rd = diffs[i];
+ switch (rd.kind()) {
+ case RangeDifference.ANCESTOR: // pseudo conflict
+ case RangeDifference.NOCHANGE:
+ case RangeDifference.RIGHT:
+ for (int j = rd.rightStart(); j < rd.rightEnd(); j++) {
+ String s= o.getLine(j);
+ output.write(s.getBytes(outputEncoding));
+ output.write(lineSeparator);
+ }
+ break;
+
+ case RangeDifference.LEFT:
+ for (int j = rd.leftStart(); j < rd.leftEnd(); j++) {
+ String s= t.getLine(j);
+ output.write(s.getBytes(outputEncoding));
+ output.write(lineSeparator);
+ }
+ break;
+
+ case RangeDifference.CONFLICT:
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, CONFLICT, MergeMessages.getString("TextAutoMerge.conflict"), null); //$NON-NLS-1$
+
+ default:
+ break;
+ }
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputEncodingError"), e); //$NON-NLS-1$
+ } catch (IOException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputIOError"), e); //$NON-NLS-1$
+ }
+
+ return Status.OK_STATUS;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugin.properties b/bundles/org.eclipse.compare/plugin.properties
index 694484aa7..e7e6a6c21 100644
--- a/bundles/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugin.properties
@@ -17,6 +17,7 @@ providerName=Eclipse.org
#
# Extension point names
#
+streamMergers= Stream Merger
structureCreators= Structure Creator
structureMergeViewers= Structure Merge Viewer
contentMergeViewers= Content Merge Viewer
diff --git a/bundles/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugin.xml
index 0f490acfc..163a0fd83 100644
--- a/bundles/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugin.xml
@@ -25,6 +25,7 @@
<!-- Compare extension point definitions -->
+ <extension-point id="streamMergers" name="%streamMergers" schema="schema/streamMergers.exsd"/>
<extension-point id="structureCreators" name="%structureCreators" schema="schema/structureCreators.exsd"/>
<extension-point id="structureMergeViewers" name="%structureMergeViewers" schema="schema/structureMergeViewers.exsd"/>
<extension-point id="contentMergeViewers" name="%contentMergeViewers" schema="schema/contentMergeViewers.exsd"/>
@@ -306,6 +307,16 @@
</action>
</objectContribution>
</extension>
+
+ <extension
+ point="org.eclipse.compare.streamMergers">
+ <structureCreator
+ extensions="txt"
+ class="org.eclipse.compare.internal.merge.TextMerger"
+ id="org.eclipse.compare.internal.merge.TextMerger">
+ </structureCreator>
+ </extension>
+
<extension
point="org.eclipse.compare.structureCreators">
<structureCreator
@@ -314,6 +325,7 @@
id="org.eclipse.compare.ZipFileStructureCreator">
</structureCreator>
</extension>
+
<extension
point="org.eclipse.compare.contentMergeViewers">
<viewer
@@ -332,6 +344,7 @@
id="org.eclipse.compare.ImageMergeViewerCreator">
</viewer>
</extension>
+
<extension
point="org.eclipse.compare.contentViewers">
<viewer
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
index 451835fcd..87f26c976 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/buildnotes_compare.html
@@ -12,6 +12,14 @@
<h1>
Eclipse Platform Build Notes<br>
Compare</h1>
+Eclipse Build Input April 20th 2004
+
+<h2>
+Problem reports fixed</h2>
+<a href="http://dev.eclipse.org/bugs/show_bug.cgi?id=54091">#54091</a>: Allow headless diff and merge<br>
+
+<h1>
+<hr WIDTH="100%"></h1>
Eclipse Build Input April 13th 2004
<h2>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
index 2eb990a18..09f477f55 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/EditionSelectionDialog.java
@@ -274,7 +274,7 @@ public class EditionSelectionDialog extends ResizableDialog {
IStructureCreator structureCreator= null;
if (ppath != null) {
String type= target.getType();
- IStructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
+ StructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
if (scd != null)
structureCreator= scd.createStructureCreator();
}
@@ -345,7 +345,7 @@ public class EditionSelectionDialog extends ResizableDialog {
IStructureCreator structureCreator= null;
if (ppath != null) {
String type= target.getType();
- IStructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
+ StructureCreatorDescriptor scd= CompareUIPlugin.getStructureCreator(type);
if (scd != null)
structureCreator= scd.createStructureCreator();
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java
new file mode 100644
index 000000000..49414b1b0
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/IStreamMerger.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * This interface defines a single operation for performing a three-way merge on three
+ * input streams. The merged result is written to an output stream.
+ * <p>
+ * Clients must implement this interface when contributing new mergers to the
+ * <code>org.eclipse.compare.streamMergers</code> extension point.
+ * </p>
+ *
+ * @see org.eclipse.compare.internal.merge.TextMerger
+ *
+ * @since 3.0
+ */
+public interface IStreamMerger {
+
+ /**
+ * Indicates the successful completion of the merge operation (value <code>IStatus.OK</code>)
+ */
+ public static final int OK= IStatus.OK;
+
+ /**
+ * Indicates that a change conflict prevented the merge from successful completion (value <code>1</code>)
+ */
+ public static final int CONFLICT= 1;
+
+ /**
+ * Status code describing an internal error (value <code>2</code>)
+ */
+ public static final int INTERNAL_ERROR= 2;
+
+ /**
+ * Performs a merge operation on the given input streams and writes the merge result to the output stream.
+ * On success a status <code>IStatus.OK</code> is returned, on error a status <code>IStatus.ERROR</code>.
+ * If the merge operation cannot deal with conflicts, the code of the error status has the value <code>IStreamMerger.CONFLICT</code>.
+ * For text oriented mergers the encoding for the input and output streams is honored.
+ *
+ * @param output the byte stream to which the merge result is written; the merger will not close the stream
+ * @param outputEncoding the encoding to use when writing to the output stream
+ * @param ancestor the byte stream from which the common ancestor is read
+ * @param ancestorEncoding the encoding of the ancestor input byte stream
+ * @param target the byte stream containing the target of the merge
+ * @param targetEncoding the encoding of the target input byte stream
+ * @param other the byte stream containing the target of the merge
+ * @param otherEncoding the encoding of the other input byte stream
+ * @param monitor reports progress of the merge operation
+ * @return returns an ISta
+ */
+ IStatus merge(OutputStream output, String outputEncoding,
+ InputStream ancestor, String ancestorEncoding,
+ InputStream target, String targetEncoding,
+ InputStream other, String otherEncoding,
+ IProgressMonitor monitor);
+}
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 d5e95ee70..ba585496e 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
@@ -70,6 +70,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
public static final String PLUGIN_ID= "org.eclipse.compare"; //$NON-NLS-1$
+ private static final String STREAM_MERGER_EXTENSION_POINT= "streamMergers"; //$NON-NLS-1$
private static final String STRUCTURE_CREATOR_EXTENSION_POINT= "structureCreators"; //$NON-NLS-1$
private static final String STRUCTURE_MERGEVIEWER_EXTENSION_POINT= "structureMergeViewers"; //$NON-NLS-1$
private static final String CONTENT_MERGEVIEWER_EXTENSION_POINT= "contentMergeViewers"; //$NON-NLS-1$
@@ -86,6 +87,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
/** Maps ImageDescriptors to Images */
private static Map fgImages2= new Hashtable(10);
+ private static Map fgStreamMergers= new Hashtable(10);
private static Map fgStructureCreators= new Hashtable(10);
private static Map fgStructureViewerDescriptors= new Hashtable(10);
private static Map fgStructureViewerAliases= new Hashtable(10);
@@ -134,56 +136,55 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
}
/**
- * Registers all structure creators, content merge viewers, and structure merge viewers
+ * Registers all stream mergers, structure creators, content merge viewers, and structure merge viewers
* that are found in the XML plugin files.
*/
private void registerExtensions() {
IPluginRegistry registry= Platform.getPluginRegistry();
+ // collect all IStreamMergers
+ IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STREAM_MERGER_EXTENSION_POINT);
+ for (int i= 0; i < elements.length; i++) {
+ StreamMergerDescriptor desc= new StreamMergerDescriptor(elements[i]);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStreamMerger(extensions, desc);
+ }
+
// collect all IStructureCreators
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT);
+ elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_CREATOR_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
- final IConfigurationElement conf= elements[i];
- String extensions= conf.getAttribute(EXTENSIONS_ATTRIBUTE);
- registerStructureCreator(extensions,
- new IStructureCreatorDescriptor() {
- public IStructureCreator createStructureCreator() {
- try {
- return (IStructureCreator) conf.createExecutableExtension(CLASS_ATTRIBUTE);
- } catch (CoreException ex) {
- log(ex.getStatus());
- }
- return null;
- }
- }
- );
+ StructureCreatorDescriptor desc= new StructureCreatorDescriptor(elements[i]);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStructureCreator(extensions, desc);
}
// collect all viewers which define the structure mergeviewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, STRUCTURE_MERGEVIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerStructureViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerStructureViewerDescriptor(extensions, desc);
}
// collect all viewers which define the content mergeviewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_MERGEVIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerContentMergeViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerContentMergeViewerDescriptor(extensions, desc);
}
// collect all viewers which define the content viewer extension point
elements= registry.getConfigurationElementsFor(PLUGIN_ID, CONTENT_VIEWER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
ViewerDescriptor desc= new ViewerDescriptor(elements[i]);
- String ext= desc.getExtension();
- if (ext != null)
- registerContentViewerDescriptor(desc.getExtension(), desc);
+ String extensions= desc.getExtension();
+ if (extensions != null)
+ registerContentViewerDescriptor(extensions, desc);
}
}
@@ -518,7 +519,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
* @param types one or more types separated by commas and whitespace
* @param descriptor the descriptor to register
*/
- public static void registerStructureCreator(String types, IStructureCreatorDescriptor descriptor) {
+ public static void registerStructureCreator(String types, StructureCreatorDescriptor descriptor) {
if (types != null) {
StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
while (tokenizer.hasMoreElements()) {
@@ -535,8 +536,8 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
* @return a descriptor for the given type, or <code>null</code> if no
* descriptor has been registered
*/
- public static IStructureCreatorDescriptor getStructureCreator(String type) {
- return (IStructureCreatorDescriptor) fgStructureCreators.get(normalizeCase(type));
+ public static StructureCreatorDescriptor getStructureCreator(String type) {
+ return (StructureCreatorDescriptor) fgStructureCreators.get(normalizeCase(type));
}
/**
@@ -580,7 +581,35 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
fgContentViewerDescriptors.put(normalizeCase(extension), descriptor);
}
}
-
+
+ /**
+ * Registers the given stream merger descriptor for one or more types.
+ *
+ * @param types one or more types separated by commas and whitespace
+ * @param descriptor the descriptor to register
+ */
+ public static void registerStreamMerger(String types, StreamMergerDescriptor descriptor) {
+ StringTokenizer tokenizer= new StringTokenizer(types, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreElements()) {
+ String extension= tokenizer.nextToken().trim();
+ fgStreamMergers.put(normalizeCase(extension), descriptor);
+ }
+ }
+
+ /**
+ * Returns a stream merger for the given type.
+ *
+ * @param type the type for which to find a stream merger
+ * @return a stream merger for the given type, or <code>null</code> if no
+ * stream merger has been registered
+ */
+ public static IStreamMerger createStreamMerger(String type) {
+ StreamMergerDescriptor descriptor= (StreamMergerDescriptor) fgStreamMergers.get(type);
+ if (descriptor != null)
+ return descriptor.createStreamMerger();
+ return null;
+ }
+
/**
* Returns a structure compare viewer based on an old viewer and an input object.
* If the old viewer is suitable for showing the input, the old viewer
@@ -616,7 +645,7 @@ public final class CompareUIPlugin extends AbstractUIPlugin {
if (vd != null)
return vd.createViewer(oldViewer, parent, configuration);
- IStructureCreatorDescriptor scc= getStructureCreator(type);
+ StructureCreatorDescriptor scc= getStructureCreator(type);
if (scc != null) {
IStructureCreator sc= scc.createStructureCreator();
if (sc != null) {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java
deleted file mode 100644
index f5a845e80..000000000
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/IStructureCreatorDescriptor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.compare.internal;
-
-import org.eclipse.compare.structuremergeviewer.IStructureCreator;
-
-/**
- * A factory object for creating <code>IStructureCreator</code>s from a descriptor.
- * <p>
- * It is used when registering <code>IStructureCreator</code> for types
- * in <code>CompareUIPlugin.registerStructureCreator</code>.
- * </p>
- *
- * @see IStructureCreator
- * @see CompareUIPlugin
- */
-public interface IStructureCreatorDescriptor {
-
- /**
- * Creates a new structure creator.
- *
- * @return a newly created structure creator
- */
- IStructureCreator createStructureCreator();
-}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
new file mode 100644
index 000000000..bebd4f177
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StreamMergerDescriptor.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.compare.IStreamMerger;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+/**
+ * A factory proxy for creating a StructureCreator.
+ */
+class StreamMergerDescriptor {
+
+ private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+
+ private IConfigurationElement fElement;
+
+ /**
+ * Creates a new sorter node with the given configuration element.
+ */
+ public StreamMergerDescriptor(IConfigurationElement element) {
+ fElement= element;
+ }
+
+ /**
+ * Creates a new stream merger from this node.
+ */
+ public IStreamMerger createStreamMerger() {
+ try {
+ return (IStreamMerger)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ } catch (CoreException ex) {
+ //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ } catch (ClassCastException ex) {
+ //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Returns the streammergers's extensions.
+ */
+ public String getExtension() {
+ return fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java
new file mode 100644
index 000000000..8d0bc78ad
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/StructureCreatorDescriptor.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+
+import org.eclipse.compare.structuremergeviewer.IStructureCreator;
+
+/**
+ * A factory proxy for creating a StructureCreator.
+ */
+public class StructureCreatorDescriptor {
+
+ private final static String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$
+ private final static String EXTENSIONS_ATTRIBUTE= "extensions"; //$NON-NLS-1$
+
+ private IConfigurationElement fElement;
+
+ /**
+ * Creates a new sorter node with the given configuration element.
+ */
+ public StructureCreatorDescriptor(IConfigurationElement element) {
+ fElement= element;
+ }
+
+ /**
+ * Creates a new sorter from this node.
+ */
+ public IStructureCreator createStructureCreator() {
+ try {
+ return (IStructureCreator)fElement.createExecutableExtension(CLASS_ATTRIBUTE);
+ } catch (CoreException ex) {
+ CompareUIPlugin.log(ex.getStatus());
+ //ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ } catch (ClassCastException ex) {
+ //ExceptionHandler.displayMessageDialog(ex, SearchMessages.getString("Search.Error.createSorter.title"), SearchMessages.getString("Search.Error.createSorter.message")); //$NON-NLS-2$ //$NON-NLS-1$
+ return null;
+ }
+ }
+
+ /**
+ * Returns the structure creator's extensions.
+ */
+ public String getExtension() {
+ return fElement.getAttribute(EXTENSIONS_ATTRIBUTE);
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
new file mode 100644
index 000000000..6cda1f25e
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/LineComparator.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal.merge;
+
+import java.io.*;
+import java.util.ArrayList;
+import org.eclipse.compare.rangedifferencer.IRangeComparator;
+
+/**
+ * This implementation of IRangeComparator breaks an input stream into lines.
+ */
+class LineComparator implements IRangeComparator {
+
+ private String[] fLines;
+
+ public LineComparator(InputStream is, String encoding) throws UnsupportedEncodingException {
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding));
+ String line;
+ ArrayList ar = new ArrayList();
+ try {
+ while ((line = br.readLine()) != null)
+ ar.add(line);
+ } catch (IOException e) {
+ }
+ try {
+ is.close();
+ } catch (IOException e1) {
+ }
+ fLines = (String[]) ar.toArray(new String[ar.size()]);
+ }
+
+ String getLine(int ix) {
+ return fLines[ix];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#getRangeCount()
+ */
+ public int getRangeCount() {
+ return fLines.length;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#rangesEqual(int, org.eclipse.compare.rangedifferencer.IRangeComparator, int)
+ */
+ public boolean rangesEqual(int thisIndex, IRangeComparator other,
+ int otherIndex) {
+ String s1 = fLines[thisIndex];
+ String s2 = ((LineComparator) other).fLines[otherIndex];
+ return s1.equals(s2);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.compare.rangedifferencer.IRangeComparator#skipRangeComparison(int, int, org.eclipse.compare.rangedifferencer.IRangeComparator)
+ */
+ public boolean skipRangeComparison(int length, int maxLength, IRangeComparator other) {
+ return false;
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java
new file mode 100644
index 000000000..e72825d2a
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.compare.internal.merge;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class MergeMessages {
+
+ private static final String RESOURCE_BUNDLE= "org.eclipse.compare.internal.merge.MergeMessages";//$NON-NLS-1$
+
+ private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+ private MergeMessages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return fgResourceBundle.getString(key);
+ } catch (MissingResourceException e) {
+ return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+ }
+ }
+}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties
new file mode 100644
index 000000000..8b55acb6c
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/MergeMessages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2004 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Common Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/cpl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+TextAutoMerge.inputEncodingError= Unsupported encoding for input streams
+TextAutoMerge.outputEncodingError= Unsupported encoding for output streams
+TextAutoMerge.outputIOError= IO error on writing
+TextAutoMerge.conflict= Conflict: cannot auto merge \ No newline at end of file
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java
new file mode 100644
index 000000000..93caa32bf
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/merge/TextMerger.java
@@ -0,0 +1,87 @@
+package org.eclipse.compare.internal.merge;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.eclipse.compare.*;
+import org.eclipse.compare.rangedifferencer.RangeDifference;
+import org.eclipse.compare.rangedifferencer.RangeDifferencer;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A simple merger for streams containing text lines.
+ */
+public class TextMerger implements IStreamMerger {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.compare.internal.merge.IAutoMerger#automerge(java.io.OutputStream,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.resources.IEncodedStorage,
+ * org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public IStatus merge(OutputStream output, String outputEncoding,
+ InputStream ancestor, String ancestorEncoding,
+ InputStream target, String targetEncoding,
+ InputStream other, String otherEncoding,
+ IProgressMonitor monitor) {
+
+ LineComparator a, t, o;
+
+ try {
+ a= new LineComparator(ancestor, ancestorEncoding);
+ t= new LineComparator(target, targetEncoding);
+ o= new LineComparator(other, otherEncoding);
+ } catch (UnsupportedEncodingException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.inputEncodingError"), e); //$NON-NLS-1$
+ }
+
+ try {
+ char lineSeparator= '\n';
+
+ RangeDifference[] diffs = RangeDifferencer.findRanges(monitor, a, t, o);
+
+ for (int i = 0; i < diffs.length; i++) {
+ RangeDifference rd = diffs[i];
+ switch (rd.kind()) {
+ case RangeDifference.ANCESTOR: // pseudo conflict
+ case RangeDifference.NOCHANGE:
+ case RangeDifference.RIGHT:
+ for (int j = rd.rightStart(); j < rd.rightEnd(); j++) {
+ String s= o.getLine(j);
+ output.write(s.getBytes(outputEncoding));
+ output.write(lineSeparator);
+ }
+ break;
+
+ case RangeDifference.LEFT:
+ for (int j = rd.leftStart(); j < rd.leftEnd(); j++) {
+ String s= t.getLine(j);
+ output.write(s.getBytes(outputEncoding));
+ output.write(lineSeparator);
+ }
+ break;
+
+ case RangeDifference.CONFLICT:
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, CONFLICT, MergeMessages.getString("TextAutoMerge.conflict"), null); //$NON-NLS-1$
+
+ default:
+ break;
+ }
+ }
+
+ } catch (UnsupportedEncodingException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputEncodingError"), e); //$NON-NLS-1$
+ } catch (IOException e) {
+ return new Status(Status.ERROR, CompareUI.PLUGIN_ID, 1, MergeMessages.getString("TextAutoMerge.outputIOError"), e); //$NON-NLS-1$
+ }
+
+ return Status.OK_STATUS;
+ }
+} \ No newline at end of file
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 694484aa7..e7e6a6c21 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.properties
@@ -17,6 +17,7 @@ providerName=Eclipse.org
#
# Extension point names
#
+streamMergers= Stream Merger
structureCreators= Structure Creator
structureMergeViewers= Structure Merge Viewer
contentMergeViewers= Content Merge Viewer
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
index 0f490acfc..163a0fd83 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/plugin.xml
@@ -25,6 +25,7 @@
<!-- Compare extension point definitions -->
+ <extension-point id="streamMergers" name="%streamMergers" schema="schema/streamMergers.exsd"/>
<extension-point id="structureCreators" name="%structureCreators" schema="schema/structureCreators.exsd"/>
<extension-point id="structureMergeViewers" name="%structureMergeViewers" schema="schema/structureMergeViewers.exsd"/>
<extension-point id="contentMergeViewers" name="%contentMergeViewers" schema="schema/contentMergeViewers.exsd"/>
@@ -306,6 +307,16 @@
</action>
</objectContribution>
</extension>
+
+ <extension
+ point="org.eclipse.compare.streamMergers">
+ <structureCreator
+ extensions="txt"
+ class="org.eclipse.compare.internal.merge.TextMerger"
+ id="org.eclipse.compare.internal.merge.TextMerger">
+ </structureCreator>
+ </extension>
+
<extension
point="org.eclipse.compare.structureCreators">
<structureCreator
@@ -314,6 +325,7 @@
id="org.eclipse.compare.ZipFileStructureCreator">
</structureCreator>
</extension>
+
<extension
point="org.eclipse.compare.contentMergeViewers">
<viewer
@@ -332,6 +344,7 @@
id="org.eclipse.compare.ImageMergeViewerCreator">
</viewer>
</extension>
+
<extension
point="org.eclipse.compare.contentViewers">
<viewer
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
index de18bd1df..f9c105f03 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentMergeViewers.exsd
@@ -99,7 +99,7 @@ for text files (extension &quot;txt&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -120,7 +120,7 @@ for text files (extension &quot;txt&quot;):
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd
index a60291803..7c66d4b35 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/contentViewers.exsd
@@ -8,8 +8,7 @@
<documentation>
This extension point allows a plug-in to register
viewers for specific content types.
-These viewers are used in the &lt;samp&gt;EditionSelectionDialog&lt;/samp&gt; when presenting an edition of a resource or a subsection thereof. The viewer
-is expected to extend &lt;samp&gt;org.eclipse.jface.viewers.Viewer&lt;/samp&gt;.
+These viewers are used in the &lt;samp&gt;EditionSelectionDialog&lt;/samp&gt; when presenting an edition of a resource or a subsection thereof. The viewer is expected to extend &lt;samp&gt;org.eclipse.jface.viewers.Viewer&lt;/samp&gt;.
However since viewers don&apos;t have a default constructor the extension point must implement the factory interface for viewers &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;.
</documentation>
</annotation>
@@ -100,7 +99,7 @@ files (extension &quot;txt&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -122,7 +121,7 @@ text and images.
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd
new file mode 100644
index 000000000..cbca7c639
--- /dev/null
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/streamMergers.exsd
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.compare">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.compare" id="streamMergers" name="Stream Merger"/>
+ </appInfo>
+ <documentation>
+ This extension point allows a plug-in to register a stream merger
+for specific content types. The stream merger is expected to perform a three-way merge
+on three input streams and write the result to an output stream.
+The extension point must implement the interface &lt;samp&gt;org.eclipse.compare.IStreamMerger&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="streamMerger" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="streamMerger">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique identifier that can be used to reference the stream merger
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ name of a class that implements &lt;samp&gt;org.eclipse.compare.IStreamMerger&lt;/samp&gt;
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.compare.IStreamMerger"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="extensions" type="string" use="required">
+ <annotation>
+ <documentation>
+ a comma separated list of file extensions e.g. &quot;java, properties&quot;
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of a stream merger for property files (extension &quot;properties&quot;):
+&lt;p&gt;
+&lt;pre&gt;
+&lt;extension point = &quot;org.eclipse.compare.streamMergers&quot;&gt;
+ &lt;streamMerger
+ id=&quot;org.eclipse.compare.merge.TextMerger&quot;
+ class=&quot;org.eclipse.compare.merge.TextMerger&quot;
+ extensions=&quot;properties&quot;
+ /&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IStreamMerger&lt;/code&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The Compare UI plugin defines a stream merger for line oriented text files.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;
+&lt;a href=&quot;hglegal.htm&quot;&gt;
+ &lt;img SRC=&quot;ngibmcpy.gif&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
+ BORDER=0 height=14 width=324&gt;&lt;/a&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd
index 189463dc4..1e66797a6 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureCreators.exsd
@@ -98,7 +98,7 @@ java files (extension &quot;java&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.structuremergeviewer.IStructureCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -119,7 +119,7 @@ java files (extension &quot;java&quot;):
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd
index 73419fdf8..06f9a0cb0 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/schema/structureMergeViewers.exsd
@@ -99,7 +99,7 @@ for zip files (extension &quot;zip&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -121,7 +121,7 @@ viewer for zip archives.
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd b/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd
index de18bd1df..f9c105f03 100644
--- a/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd
+++ b/bundles/org.eclipse.compare/schema/contentMergeViewers.exsd
@@ -99,7 +99,7 @@ for text files (extension &quot;txt&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -120,7 +120,7 @@ for text files (extension &quot;txt&quot;):
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/schema/contentViewers.exsd b/bundles/org.eclipse.compare/schema/contentViewers.exsd
index a60291803..7c66d4b35 100644
--- a/bundles/org.eclipse.compare/schema/contentViewers.exsd
+++ b/bundles/org.eclipse.compare/schema/contentViewers.exsd
@@ -8,8 +8,7 @@
<documentation>
This extension point allows a plug-in to register
viewers for specific content types.
-These viewers are used in the &lt;samp&gt;EditionSelectionDialog&lt;/samp&gt; when presenting an edition of a resource or a subsection thereof. The viewer
-is expected to extend &lt;samp&gt;org.eclipse.jface.viewers.Viewer&lt;/samp&gt;.
+These viewers are used in the &lt;samp&gt;EditionSelectionDialog&lt;/samp&gt; when presenting an edition of a resource or a subsection thereof. The viewer is expected to extend &lt;samp&gt;org.eclipse.jface.viewers.Viewer&lt;/samp&gt;.
However since viewers don&apos;t have a default constructor the extension point must implement the factory interface for viewers &lt;samp&gt;org.eclipse.compare.IViewerCreator&lt;/samp&gt;.
</documentation>
</annotation>
@@ -100,7 +99,7 @@ files (extension &quot;txt&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -122,7 +121,7 @@ text and images.
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/schema/streamMergers.exsd b/bundles/org.eclipse.compare/schema/streamMergers.exsd
new file mode 100644
index 000000000..cbca7c639
--- /dev/null
+++ b/bundles/org.eclipse.compare/schema/streamMergers.exsd
@@ -0,0 +1,126 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.compare">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.compare" id="streamMergers" name="Stream Merger"/>
+ </appInfo>
+ <documentation>
+ This extension point allows a plug-in to register a stream merger
+for specific content types. The stream merger is expected to perform a three-way merge
+on three input streams and write the result to an output stream.
+The extension point must implement the interface &lt;samp&gt;org.eclipse.compare.IStreamMerger&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="streamMerger" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="streamMerger">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique identifier that can be used to reference the stream merger
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ name of a class that implements &lt;samp&gt;org.eclipse.compare.IStreamMerger&lt;/samp&gt;
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.compare.IStreamMerger"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="extensions" type="string" use="required">
+ <annotation>
+ <documentation>
+ a comma separated list of file extensions e.g. &quot;java, properties&quot;
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of a stream merger for property files (extension &quot;properties&quot;):
+&lt;p&gt;
+&lt;pre&gt;
+&lt;extension point = &quot;org.eclipse.compare.streamMergers&quot;&gt;
+ &lt;streamMerger
+ id=&quot;org.eclipse.compare.merge.TextMerger&quot;
+ class=&quot;org.eclipse.compare.merge.TextMerger&quot;
+ extensions=&quot;properties&quot;
+ /&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IStreamMerger&lt;/code&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ The Compare UI plugin defines a stream merger for line oriented text files.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;
+&lt;a href=&quot;hglegal.htm&quot;&gt;
+ &lt;img SRC=&quot;ngibmcpy.gif&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
+ BORDER=0 height=14 width=324&gt;&lt;/a&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/bundles/org.eclipse.compare/schema/structureCreators.exsd b/bundles/org.eclipse.compare/schema/structureCreators.exsd
index 189463dc4..1e66797a6 100644
--- a/bundles/org.eclipse.compare/schema/structureCreators.exsd
+++ b/bundles/org.eclipse.compare/schema/structureCreators.exsd
@@ -98,7 +98,7 @@ java files (extension &quot;java&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.structuremergeviewer.IStructureCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -119,7 +119,7 @@ java files (extension &quot;java&quot;):
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd b/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd
index 73419fdf8..06f9a0cb0 100644
--- a/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd
+++ b/bundles/org.eclipse.compare/schema/structureMergeViewers.exsd
@@ -99,7 +99,7 @@ for zip files (extension &quot;zip&quot;):
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
-
+ The contributed class must implement &lt;code&gt;org.eclipse.compare.IViewerCreator&lt;/code&gt;
</documentation>
</annotation>
@@ -121,7 +121,7 @@ viewer for zip archives.
&lt;p&gt;
&lt;a href=&quot;hglegal.htm&quot;&gt;
&lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ ALT=&quot;Copyright (c) 2000, 2004 IBM Corporation and others. All Rights Reserved.&quot;
BORDER=0 height=14 width=324&gt;&lt;/a&gt;
&lt;/p&gt;
</documentation>
diff --git a/tests/org.eclipse.compare.tests/.classpath b/tests/org.eclipse.compare.tests/.classpath
index b26755e21..0c6403796 100644
--- a/tests/org.eclipse.compare.tests/.classpath
+++ b/tests/org.eclipse.compare.tests/.classpath
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="JUnit Tests"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java
index 087c77f98..02c5a4f72 100644
--- a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java
+++ b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/AllTests.java
@@ -22,6 +22,7 @@ public class AllTests {
public static Test suite() {
TestSuite suite= new TestSuite("Test for org.eclipse.compare.tests"); //$NON-NLS-1$
//$JUnit-BEGIN$
+ suite.addTestSuite(StreamMergerTest.class);
suite.addTestSuite(DocLineComparatorTest.class);
suite.addTestSuite(FilterTest.class);
//$JUnit-END$
diff --git a/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/StreamMergerTest.java b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/StreamMergerTest.java
new file mode 100644
index 000000000..94b661ae1
--- /dev/null
+++ b/tests/org.eclipse.compare.tests/JUnit Tests/org/eclipse/compare/tests/StreamMergerTest.java
@@ -0,0 +1,148 @@
+/*
+ * Created on Apr 12, 2004
+ *
+ * To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package org.eclipse.compare.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.compare.IStreamMerger;
+import org.eclipse.compare.internal.merge.TextMerger;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+
+public class StreamMergerTest extends TestCase {
+
+ String encoding= "UTF-8"; //$NON-NLS-1$
+
+ public StreamMergerTest(String name) {
+ super(name);
+ }
+
+ public void testIncomingAddition() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String o= "abc\ndef\n123\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\ndef\n123\nxyz\n"); //$NON-NLS-1$
+ }
+
+ public void testIncomingDeletion() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String o= "abc\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\nxyz\n"); //$NON-NLS-1$
+ }
+
+ public void testIncomingReplacement() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String o= "abc\n123\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\n123\nxyz\n"); //$NON-NLS-1$
+ }
+
+ public void testNonConflictingMerge() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\ndef\nxyz\nfoo"; //$NON-NLS-1$
+ String o= "abc\n123\n456\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\n123\n456\nxyz\nfoo\n"); //$NON-NLS-1$
+ }
+
+ public void testConflictingReplacement() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\nfoo\nxyz"; //$NON-NLS-1$
+ String o= "abc\nbar\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.ERROR);
+ assertEquals(status.getCode(), IStreamMerger.CONFLICT);
+ }
+
+ public void testConflictingAddition() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\ndef\n123\nxyz"; //$NON-NLS-1$
+ String o= "abc\ndef\n123\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\ndef\n123\nxyz\n"); //$NON-NLS-1$
+ }
+
+ public void testConflictingDeletion() throws UnsupportedEncodingException {
+
+ String a= "abc\ndef\nxyz"; //$NON-NLS-1$
+ String t= "abc\nxyz"; //$NON-NLS-1$
+ String o= "abc\nxyz"; //$NON-NLS-1$
+
+ StringBuffer output= new StringBuffer();
+
+ IStatus status= merge(output, a, t, o);
+
+ assertEquals(status.getSeverity(), IStatus.OK);
+ assertEquals(status.getCode(), IStatus.OK);
+ assertEquals(output.toString(), "abc\nxyz\n"); //$NON-NLS-1$
+ }
+
+ private IStatus merge(StringBuffer output, String a, String m, String y) throws UnsupportedEncodingException {
+ InputStream ancestor= new ByteArrayInputStream(a.getBytes(encoding));
+ InputStream target= new ByteArrayInputStream(m.getBytes(encoding));
+ InputStream other= new ByteArrayInputStream(y.getBytes(encoding));
+
+ ByteArrayOutputStream os= new ByteArrayOutputStream();
+
+ IStreamMerger merger= new TextMerger();
+ IStatus status= merger.merge(os, encoding, ancestor, encoding, target, encoding, other, encoding, (IProgressMonitor)null);
+
+ output.append(new String(os.toByteArray(), encoding));
+
+ return status;
+ }
+}
diff --git a/tests/org.eclipse.compare.tests/plugin.xml b/tests/org.eclipse.compare.tests/plugin.xml
index 245ae9270..9ff939a0e 100644
--- a/tests/org.eclipse.compare.tests/plugin.xml
+++ b/tests/org.eclipse.compare.tests/plugin.xml
@@ -18,6 +18,7 @@
<import plugin="org.eclipse.jface.text"/>
<import plugin="org.eclipse.jface"/>
<import plugin="org.eclipse.jdt.junit"/>
+ <import plugin="org.eclipse.core.runtime"/>
</requires>

Back to the top