Package org.eclipse.jface.text
Interface IDocumentExtension4
- All Known Implementing Classes:
- AbstractDocument,- ChildDocument,- Document,- ProjectionDocument
public interface IDocumentExtension4
Extension interface for 
IDocument. It adds the
 following concepts:
 - Rewrite sessions. A rewrite session is a sequence of replace operations that form a semantic unit.
- A modification stamp on the document
- The ability to set the initial line delimiter and to query the default line delimiter
- Since:
- 3.1
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final longThe unknown modification stamp.
- 
Method SummaryModifier and TypeMethodDescriptionvoidRegisters the document rewrite session listener with the document.Returns the active rewrite session of this document ornull.Returns this document's default line delimiter.longReturns the modification stamp of this document.voidRemoves the listener from the document's list of document rewrite session listeners.voidSubstitutes the given text for the specified document range.voidReplaces the content of the document with the given text.voidsetInitialLineDelimiter(String lineDelimiter) Sets this document's initial line delimiter i.e. the one which is returned bygetDefaultLineDelimiterif the document does not yet contain any line delimiter.startRewriteSession(DocumentRewriteSessionType sessionType) Tells the document that it is about to be rewritten.voidstopRewriteSession(DocumentRewriteSession session) Tells the document to stop the rewrite session.
- 
Field Details- 
UNKNOWN_MODIFICATION_STAMPstatic final long UNKNOWN_MODIFICATION_STAMPThe unknown modification stamp.- See Also:
 
 
- 
- 
Method Details- 
startRewriteSessionDocumentRewriteSession startRewriteSession(DocumentRewriteSessionType sessionType) throws IllegalStateException Tells the document that it is about to be rewritten. That is, a sequence of replace operations that form a semantic unit will be performed on this document. A specification of the nature of the operation sequence is given in form of the session type.The document is considered being in rewrite mode as long as stopRewriteSessionhas not been called.- Parameters:
- sessionType- the session type
- Returns:
- the started rewrite session
- Throws:
- IllegalStateException- in case there is already an active rewrite session
 
- 
stopRewriteSessionTells the document to stop the rewrite session. This method has only any effect ifstartRewriteSessionhas been called before.This method does not have any effect if the given session is not the active rewrite session. - Parameters:
- session- the session to stop
 
- 
getActiveRewriteSessionDocumentRewriteSession getActiveRewriteSession()Returns the active rewrite session of this document ornull.- Returns:
- the active rewrite session or null
 
- 
addDocumentRewriteSessionListenerRegisters the document rewrite session listener with the document. After registration theIDocumentRewriteSessionListeneris informed about each state change of rewrite sessions performed on this document.If the listener is already registered nothing happens. An IRewriteSessionDocumentListenermay call back to this document when being inside a document notification.- Parameters:
- listener- the listener to be registered
 
- 
removeDocumentRewriteSessionListenerRemoves the listener from the document's list of document rewrite session listeners. If the listener is not registered with the document nothing happens.An IDocumentRewriteSessionListenermay call back to this document when being inside a document notification.- Parameters:
- listener- the listener to be removed
 
- 
replacevoid replace(int offset, int length, String text, long modificationStamp) throws BadLocationException Substitutes the given text for the specified document range. Sends aDocumentEventto all registeredIDocumentListener.- Parameters:
- offset- the document offset
- length- the length of the specified range
- text- the substitution text
- modificationStamp- of the document after replacing
- Throws:
- BadLocationException- if the offset is invalid in this document
- See Also:
 
- 
setReplaces the content of the document with the given text. Sends aDocumentEventto all registeredIDocumentListener. This method is a convenience method forreplace(0, getLength(), text).- Parameters:
- text- the new content of the document
- modificationStamp- of the document after setting the content
- See Also:
 
- 
getModificationStamplong getModificationStamp()Returns the modification stamp of this document. The modification stamp is updated each time a modifying operation is called on this document. If two modification stamps of the same document are identical then the document content is too, however, same content does not imply same modification stamp.The magnitude or sign of the numerical difference between two modification stamps is not significant. - Returns:
- the modification stamp of this document or UNKNOWN_MODIFICATION_STAMP
 
- 
getDefaultLineDelimiterString getDefaultLineDelimiter()Returns this document's default line delimiter.This default line delimiter should be used by clients who want unique delimiters (e.g. 'CR's) in the document. - Returns:
- the default line delimiter or nullif none
 
- 
setInitialLineDelimiterSets this document's initial line delimiter i.e. the one which is returned bygetDefaultLineDelimiterif the document does not yet contain any line delimiter.- Parameters:
- lineDelimiter- the default line delimiter
 
 
-