public class DocumentChange extends TextChange
IDocument. The document change uses a simple length compare to check if it is still valid. So as long as its length hasn't changed the text edits managed have a valid range and can be applied to the document. The same applies to the undo change returned from the perform method.
Note: this class is not intended to be extended by clients.
|Constructor and Description|
Creates a new
|Modifier and Type||Method and Description|
Acquires a reference to the document to be changed by this text change.
Commits the document acquired via a call to
Hook to create an undo change for the given undo edit.
Returns the element modified by this
Hook method to initialize some internal state to provide an adequate answer for the
Verifies that this change object is still valid and can be executed by calling
Executes the text edits on the given document.
Releases the document acquired via a call to
addEdit, addTextEditChangeGroup, addTextEditGroup, getCurrentContent, getCurrentContent, getCurrentDocument, getEdit, getPreviewContent, getPreviewContent, getPreviewContent, getPreviewDocument, getPreviewEdit, getPreviewEdits, getTextEditChangeGroups, perform, setEdit, setKeepPreviewEdits
addChangeGroup, getChangeGroups, getKeepPreviewEdits, getName, getTextType, hasOneGroupCategory, setEnabled, setTextType
dispose, getAdapter, getAffectedObjects, getDescriptor, getParent, isEnabled, setEnabledShallow
public Object getModifiedElement()
Change. The method may return
nullif the change isn't related to an element.
public void initializeValidationData(IProgressMonitor pm)
isValidmethod. This method gets called after a change or a whole change tree has been created.
Typically this method is implemented in one of the following ways:
For example, a change object that manipulates the content of an
could either listen to resource changes and detect that the file got changed or
it could remember some content stamp and compare it with the actual content stamp
isValid is called.
public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException
perform. If a refactoring status with a severity of
RefactoringStatus.FATALis returned then the change has to be treated as invalid and can no longer be executed. Performing such a change produces an unspecified result and will very likely throw an exception.
This method is also called by the
UndoManager to decide if
an undo or redo change is still valid and therefore can be executed.
protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException
releaseDocument must be called as many times as
aquireDocument has been called.
protected void commit(IDocument document, IProgressMonitor pm) throws CoreException
aquireDocument. It is up to the implementors of this method to decide what committing a document means. Typically, the content of the document is written back to the file system.
protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException
protected UndoEdit performEdits(IDocument document) throws BadLocationException, MalformedTreeException
document- the document
BadLocationException- is thrown if one of the edits in the tree can't be executed. The state of the document is undefined if this exception is thrown.
MalformedTreeException- is thrown if the edit tree isn't in a valid state. This exception is thrown before any edit is executed. So the document is still in its original state.
UndoEditto create an undo change for
nullif no undo change can be created. Returning
nullresults in the fact that the whole change tree can't be undone. So returning
nullis only recommended if an exception occurred during the creation of the undo change.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.