|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.compare.structuremergeviewer
Class DocumentRangeNode

java.lang.Objectorg.eclipse.compare.structuremergeviewer.DocumentRangeNode
- All Implemented Interfaces:
- org.eclipse.compare.contentmergeviewer.IDocumentRange, org.eclipse.compare.IEditableContent, org.eclipse.compare.IEncodedStreamContentAccessor, org.eclipse.compare.IStreamContentAccessor, IStructureComparator
- public class DocumentRangeNode
- extends java.lang.Object
- implements org.eclipse.compare.contentmergeviewer.IDocumentRange, IStructureComparator, org.eclipse.compare.IEditableContent, org.eclipse.compare.IEncodedStreamContentAccessor
- extends java.lang.Object
A document range node represents a structural element
when performing a structure compare of documents.
DocumentRangeNodes are created while parsing the document and represent
a semantic entity (e.g. a Java class or method).
As a consequence of the parsing a DocumentRangeNode maps to a range
of characters in the document.
Since a DocumentRangeNode implements the IStructureComparator
and IStreamContentAccessor interfaces it can be used as input to the
differencing engine. This makes it possible to perform
a structural diff on a document and have the nodes and leaves of the compare easily map
to character ranges within the document.
Subclasses may add additional state collected while parsing the document.
| Field Summary | |
private org.eclipse.jface.text.Position |
fAppendPosition
|
private org.eclipse.jface.text.IDocument |
fBaseDocument
|
private java.util.ArrayList |
fChildren
|
private java.lang.String |
fID
|
private org.eclipse.jface.text.Position |
fRange
|
private int |
fTypeCode
|
private static boolean |
POS_UPDATE
|
private static java.lang.String |
UTF_16
|
| Fields inherited from interface org.eclipse.compare.contentmergeviewer.IDocumentRange |
RANGE_CATEGORY |
| Constructor Summary | |
DocumentRangeNode(int typeCode,
java.lang.String id,
org.eclipse.jface.text.IDocument document,
int start,
int length)
Creates a new DocumentRangeNode for the given range within the specified
document. |
|
| Method Summary | |
private void |
add(java.lang.String s,
DocumentRangeNode parent,
DocumentRangeNode child)
|
void |
addChild(DocumentRangeNode node)
Adds the given node as a child. |
boolean |
equals(java.lang.Object other)
Implementation based on getID. |
private org.eclipse.jface.text.Position |
findCorrespondingPosition(DocumentRangeNode otherParent,
DocumentRangeNode child)
Find corresponding position |
org.eclipse.jface.text.Position |
getAppendPosition()
Returns the position that has been set with setAppendPosition. |
java.lang.String |
getCharset()
Returns the name of a charset encoding to be used when decoding this stream accessor's contents into characters. |
java.lang.Object[] |
getChildren()
Returns an iterator for all children of this object or null
if there are no children. |
java.io.InputStream |
getContents()
Returns an open InputStream for this object which can be used to retrieve the object's content. |
org.eclipse.jface.text.IDocument |
getDocument()
Returns the underlying document. |
java.lang.String |
getId()
Returns this node's id. |
org.eclipse.jface.text.Position |
getRange()
Returns a position that specifies a subrange in the underlying document, or null if this document range spans the whole underlying document. |
int |
getTypeCode()
Returns the type code of this node. |
int |
hashCode()
Implementation based on getID. |
boolean |
isEditable()
Returns true if this object can be modified. |
org.eclipse.compare.ITypedElement |
replace(org.eclipse.compare.ITypedElement child,
org.eclipse.compare.ITypedElement other)
This method is called on a parent to add or remove a child, or to copy the contents of a child. |
void |
setAppendPosition(int pos)
Sets a position within the document range that can be used to (legally) insert text without breaking the syntax of the document. |
void |
setContent(byte[] content)
Replaces the current content with the given new bytes. |
void |
setId(java.lang.String id)
Sets this node's id. |
void |
setLength(int length)
Sets the length of the range of this node. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
POS_UPDATE
private static final boolean POS_UPDATE
- See Also:
- Constant Field Values
UTF_16
private static final java.lang.String UTF_16
- See Also:
- Constant Field Values
fBaseDocument
private org.eclipse.jface.text.IDocument fBaseDocument
fRange
private org.eclipse.jface.text.Position fRange
fTypeCode
private int fTypeCode
fID
private java.lang.String fID
fAppendPosition
private org.eclipse.jface.text.Position fAppendPosition
fChildren
private java.util.ArrayList fChildren
| Constructor Detail |
DocumentRangeNode
public DocumentRangeNode(int typeCode,
java.lang.String id,
org.eclipse.jface.text.IDocument document,
int start,
int length)
- Creates a new
DocumentRangeNodefor the given range within the specified document. ThetypeCodeis uninterpreted client data. The ID is used when comparing two nodes with each other: i.e. the differencing engine performs a content compare on two nodes if their IDs are equal.
| Method Detail |
getDocument
public org.eclipse.jface.text.IDocument getDocument()
- Description copied from interface:
org.eclipse.compare.contentmergeviewer.IDocumentRange - Returns the underlying document.
- Specified by:
getDocumentin interfaceorg.eclipse.compare.contentmergeviewer.IDocumentRange
getRange
public org.eclipse.jface.text.Position getRange()
- Description copied from interface:
org.eclipse.compare.contentmergeviewer.IDocumentRange - Returns a position that specifies a subrange in the underlying document,
or
nullif this document range spans the whole underlying document.- Specified by:
getRangein interfaceorg.eclipse.compare.contentmergeviewer.IDocumentRange
getTypeCode
public int getTypeCode()
- Returns the type code of this node.
The type code is uninterpreted client data which can be set in the constructor.
getId
public java.lang.String getId()
- Returns this node's id.
It is used in
equalsandhashcode.
setId
public void setId(java.lang.String id)
- Sets this node's id.
It is used in
equalsandhashcode.
addChild
public void addChild(DocumentRangeNode node)
- Adds the given node as a child.
getChildren
public java.lang.Object[] getChildren()
- Description copied from interface:
IStructureComparator - Returns an iterator for all children of this object or
nullif there are no children.- Specified by:
getChildrenin interfaceIStructureComparator
setLength
public void setLength(int length)
- Sets the length of the range of this node.
setAppendPosition
public void setAppendPosition(int pos)
- Sets a position within the document range that can be used to (legally) insert
text without breaking the syntax of the document.
E.g. when parsing a Java document the "append position" of a
DocumentRangeNoderepresentating a Java class could be the character position just before the closing bracket. Inserting the text of a new method there would not disturb the syntax of the class.
getAppendPosition
public org.eclipse.jface.text.Position getAppendPosition()
- Returns the position that has been set with
setAppendPosition. IfsetAppendPositionhasn't been called, the position after the last character of this range is returned.
equals
public boolean equals(java.lang.Object other)
- Implementation based on
getID.- Specified by:
equalsin interfaceIStructureComparator
hashCode
public int hashCode()
- Implementation based on
getID.
findCorrespondingPosition
private org.eclipse.jface.text.Position findCorrespondingPosition(DocumentRangeNode otherParent, DocumentRangeNode child)
- Find corresponding position
add
private void add(java.lang.String s, DocumentRangeNode parent, DocumentRangeNode child)
getContents
public java.io.InputStream getContents()
- Description copied from interface:
org.eclipse.compare.IStreamContentAccessor - Returns an open
InputStreamfor this object which can be used to retrieve the object's content. The client is responsible for closing the stream when finished. Returnsnullif this object has no streamable contents.- Specified by:
getContentsin interfaceorg.eclipse.compare.IStreamContentAccessor
isEditable
public boolean isEditable()
- Description copied from interface:
org.eclipse.compare.IEditableContent - Returns
trueif this object can be modified. If it returnsfalsethe other methods of this API must not be called.- Specified by:
isEditablein interfaceorg.eclipse.compare.IEditableContent
replace
public org.eclipse.compare.ITypedElement replace(org.eclipse.compare.ITypedElement child, org.eclipse.compare.ITypedElement other)
- Description copied from interface:
org.eclipse.compare.IEditableContent - This method is called on a parent to add or remove a child,
or to copy the contents of a child.
What to do is encoded in the two arguments as follows:
add: child == null other != null remove: child != null other == null copy: child != null other != null - Specified by:
replacein interfaceorg.eclipse.compare.IEditableContent
setContent
public void setContent(byte[] content)
- Description copied from interface:
org.eclipse.compare.IEditableContent - Replaces the current content with the given new bytes.
- Specified by:
setContentin interfaceorg.eclipse.compare.IEditableContent
getCharset
public java.lang.String getCharset()
- Description copied from interface:
org.eclipse.compare.IEncodedStreamContentAccessor - Returns the name of a charset encoding to be used when decoding this
stream accessor's contents into characters. Returns
nullif a proper encoding cannot be determined.Note: this method does not check whether the result is a supported charset name. Callers should be prepared to handle
UnsupportedEncodingExceptionwhere this charset is used.- Specified by:
getCharsetin interfaceorg.eclipse.compare.IEncodedStreamContentAccessor
|
|||||||||
| Home >> All >> org >> eclipse >> compare >> [ structuremergeviewer overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.eclipse.compare.structuremergeviewer.DocumentRangeNode