A text merge viewer uses the RangeDifferencer to perform a
textual, line-by-line comparison of two (or three) input documents.
It is based on the ContentMergeViewer and uses TextViewers
to implement the ancestor, left, and right content areas.
In the three-way compare case ranges of differing lines are highlighted and framed
with different colors to show whether the difference is an incoming, outgoing, or conflicting change.
The TextMergeViewer supports the notion of a current "differing range"
and provides toolbar buttons to navigate from one range to the next (or previous).
If there is a current "differing range" and the underlying document is editable
the TextMergeViewer enables actions in context menu and toolbar to
copy a range from one side to the other side, thereby performing a merge operation.
In addition to a line-by-line comparison the TextMergeViewer
uses a token based compare on differing lines.
The token compare is activated when navigating into
a range of differing lines. At first the lines are selected as a block.
When navigating into this block the token compare shows for every line
the differing token by selecting them.
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 and overriding the
TextMergeViewer.createTokenComparator factory method).
Access to the TextMergeViewer's model is by means of an
IMergeViewerContentProvider. Its getXContent methods must return
either an IDocument, an IDocumentRange, or an IStreamContentAccessor.
In the IDocumentRange case the TextMergeViewer
works on a subrange of a document. In the IStreamContentAccessor case
a document is created internally and initialized from the stream.
A TextMergeViewer can be used as is. However clients may subclass
to customize the behavior. For example a MergeTextViewer for Java would override
the configureTextViewer method to configure the TextViewer for Java source code,
the createTokenComparator method to create a Java specific tokenizer.
RangeDifferencerto perform a textual, line-by-line comparison of two (or three) input documents. It is based on theContentMergeViewerand usesTextViewers to implement the ancestor, left, and right content areas.In the three-way compare case ranges of differing lines are highlighted and framed with different colors to show whether the difference is an incoming, outgoing, or conflicting change. The
TextMergeViewersupports the notion of a current "differing range" and provides toolbar buttons to navigate from one range to the next (or previous).If there is a current "differing range" and the underlying document is editable the
TextMergeViewerenables actions in context menu and toolbar to copy a range from one side to the other side, thereby performing a merge operation.In addition to a line-by-line comparison the
TextMergeVieweruses a token based compare on differing lines. The token compare is activated when navigating into a range of differing lines. At first the lines are selected as a block. When navigating into this block the token compare shows for every line the differing token by selecting them.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 theITokenComparatorinterface and overriding theTextMergeViewer.createTokenComparatorfactory method).Access to the
TextMergeViewer's model is by means of anIMergeViewerContentProvider. ItsgetX Content methods must return either anIDocument, anIDocumentRange, or anIStreamContentAccessor. In theIDocumentRangecase theTextMergeViewerworks on a subrange of a document. In theIStreamContentAccessorcase a document is created internally and initialized from the stream.A
TextMergeViewercan be used as is. However clients may subclass to customize the behavior. For example aMergeTextViewerfor Java would override theconfigureTextViewermethod to configure theTextViewerfor Java source code, thecreateTokenComparatormethod to create a Java specific tokenizer.