Package org.eclipse.text.edits
Class TextEditProcessor
java.lang.Object
org.eclipse.text.edits.TextEditProcessor
- Direct Known Subclasses:
RewriteSessionEditProcessor
A
TextEditProcessor manages a set of edits and applies
them as a whole to an IDocument.
This class isn't intended to be subclassed.
- Since:
- 3.0
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
ConstructorsConstructorDescriptionTextEditProcessor(IDocument document, TextEdit root, int style) Constructs a new edit processor for the given document. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the processor can execute all its edits.protected booleanconsiderEdit(TextEdit edit) Tells whether this processor considers the given edit.Returns the document to be manipulated.getRoot()Returns the edit processor's root edit.intgetStyle()Returns the style bits of the text edit processorExecutes the text edits.
-
Constructor Details
-
TextEditProcessor
Constructs a new edit processor for the given document.- Parameters:
document- the document to manipulateroot- the root of the text edit tree describing the modifications. By passing a text edit a a text edit processor the ownership of the edit is transfered to the text edit processors. Clients must not modify the edit (e.g adding new children) any longer.style-TextEdit.NONE,TextEdit.CREATE_UNDOorTextEdit.UPDATE_REGIONS)
-
-
Method Details
-
getDocument
Returns the document to be manipulated.- Returns:
- the document
-
getRoot
Returns the edit processor's root edit.- Returns:
- the processor's root edit
-
getStyle
public int getStyle()Returns the style bits of the text edit processor- Returns:
- the style bits
- See Also:
-
canPerformEdits
public boolean canPerformEdits()Checks if the processor can execute all its edits.- Returns:
trueif the edits can be executed. Returnfalseotherwise. One major reason why edits cannot be executed are wrong offset or length values of edits. Calling perform in this case will very likely end in aBadLocationException.
-
performEdits
Executes the text edits.- Returns:
- an object representing the undo of the executed edits
- Throws:
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.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.
-
considerEdit
Tells whether this processor considers the given edit.Note that this class isn't intended to be subclassed.
- Parameters:
edit- the text edit- Returns:
trueif this processor considers the given edit
-