# Package org.eclipse.compare.contentmergeviewer

package org.eclipse.compare.contentmergeviewer
Support for compare and merge viewers which show the content side-by-side.

## Package Specification

The ContentMergeViewer is an abstract compare and merge viewer with two side-by-side content areas and an optional content area for a common ancestor (for three-way compare). Because the implementation makes no assumptions about the content type it is a subclass responsibility to deal with a specific type. Its subclass ImageMergeViewer in package org.eclipse.compare.internal shows how to base a simple mergeviewer for images on ContentMergeViewer.

A ContentMergeViewer accesses its model by means of a content provider which must implement the IMergeViewerContentProvider interface.

The TextMergeViewer is the standard concrete subclass of ContentMergeViewer for comparing and merging text content.
A text merge viewer uses the org.eclipse.compare.rangedifferencer.RangeDifferencer to perform a textual, line-by-line comparison of two (or three) input documents. For text lines that differ the TextMergeViewer uses an ITokenComparator to find longest sequences of matching and non-matching tokens. The TextMergeViewer's default token compare works on characters separated by whitespace. If a different strategy is needed (for example, Java tokens in a Java-aware merge viewer), clients can create their own token comparators by implementing the ITokenComparator interface.

The TextMergeViewer not only works on whole documents but on subranges of documents too. In this case the viewer's input must be an IDocumentRange instead of an IDocument.

Related Packages
Package
Description
org.eclipse.compare
Provides support for performing structural and textual compare operations on arbitrary data and displaying the results.
org.eclipse.compare.patch
Provides support for applying and working with patches.
org.eclipse.compare.rangedifferencer
Provides support for finding the differences between two or three sequences of comparable entities.
org.eclipse.compare.structuremergeviewer
Provides support for finding and displaying the differences between hierarchically structured data.
Class
Description
ContentMergeViewer
An abstract compare and merge viewer with two side-by-side content areas and an optional content area for the ancestor.
IDocumentRange
Defines a subrange in a document.
IFlushable
Interface which provides the ability to flush the contents from the viewer model (for example, an `IDocument` for text based content) into the underlying compare model ( most likely an instance of `IEditableContent`).
IIgnoreWhitespaceContributor
IMergeViewerContentProvider
A content provider that mediates between a `ContentMergeViewer`'s model and the viewer itself.
ITokenComparator
For performing a so-called "token compare" on a line of text.
TextMergeViewer
A text merge viewer uses the `RangeDifferencer` to perform a textual, line-by-line comparison of two (or three) input documents.
TokenComparator
Implements the `ITokenComparator` interface for words (or tokens) in a string.