Package org.eclipse.handly.buffer
Class BufferChangeOperation
- java.lang.Object
-
- org.eclipse.handly.buffer.BufferChangeOperation
-
public class BufferChangeOperation extends java.lang.Object
Applies a given change to a givenIBuffer
. This class is intended to be used in implementations ofIBuffer
. General clients should useIBuffer.applyChange(IBufferChange, IProgressMonitor)
instead.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BufferChangeOperation.ChangeEditProcessor
protected static class
BufferChangeOperation.UndoChange
-
Field Summary
Fields Modifier and Type Field Description protected IBuffer
buffer
protected IBufferChange
change
-
Constructor Summary
Constructors Constructor Description BufferChangeOperation(IBuffer buffer, IBufferChange change)
Creates a new operation that can apply the given change to the given buffer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IBufferChange
applyChange(org.eclipse.core.runtime.IProgressMonitor monitor)
protected org.eclipse.text.edits.UndoEdit
applyTextEdit()
protected void
checkChange()
protected org.eclipse.text.edits.TextEditProcessor
createTextEditProcessor()
protected IBufferChange
createUndoChange(org.eclipse.text.edits.UndoEdit undoEdit, long stampToRestore)
IBufferChange
execute(org.eclipse.core.runtime.IProgressMonitor monitor)
Executes the buffer change.protected static long
getModificationStampOf(org.eclipse.jface.text.IDocument document)
protected static void
setModificationStampOf(org.eclipse.jface.text.IDocument document, long modificationStamp)
-
-
-
Field Detail
-
buffer
protected final IBuffer buffer
-
change
protected final IBufferChange change
-
-
Constructor Detail
-
BufferChangeOperation
public BufferChangeOperation(IBuffer buffer, IBufferChange change)
Creates a new operation that can apply the given change to the given buffer.- Parameters:
buffer
- must not benull
change
- must not benull
-
-
Method Detail
-
execute
public IBufferChange execute(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, org.eclipse.jface.text.BadLocationException
Executes the buffer change.Note that an update conflict may occur if the buffer's contents have changed since the inception of the snapshot on which the change is based. In that case, a
StaleSnapshotException
is thrown.- Parameters:
monitor
- a progress monitor (notnull
). The caller must not rely onIProgressMonitor.done()
having been called by the receiver- Returns:
- undo change, if requested by the change. Otherwise,
null
- Throws:
StaleSnapshotException
- if the buffer has changed since the inception of the snapshot on which the change is basedorg.eclipse.core.runtime.CoreException
- if save is requested by the change but the buffer could not be savedorg.eclipse.text.edits.MalformedTreeException
- if the change's edit tree is not in a valid stateorg.eclipse.jface.text.BadLocationException
- if one of the edits in the change's edit tree could not be executed
-
applyChange
protected IBufferChange applyChange(org.eclipse.core.runtime.IProgressMonitor monitor) throws org.eclipse.core.runtime.CoreException, org.eclipse.jface.text.BadLocationException
- Throws:
org.eclipse.core.runtime.CoreException
org.eclipse.jface.text.BadLocationException
-
checkChange
protected void checkChange() throws org.eclipse.core.runtime.CoreException
- Throws:
org.eclipse.core.runtime.CoreException
-
applyTextEdit
protected org.eclipse.text.edits.UndoEdit applyTextEdit() throws org.eclipse.jface.text.BadLocationException
- Throws:
org.eclipse.jface.text.BadLocationException
-
createTextEditProcessor
protected org.eclipse.text.edits.TextEditProcessor createTextEditProcessor()
-
createUndoChange
protected IBufferChange createUndoChange(org.eclipse.text.edits.UndoEdit undoEdit, long stampToRestore)
-
getModificationStampOf
protected static long getModificationStampOf(org.eclipse.jface.text.IDocument document)
-
setModificationStampOf
protected static void setModificationStampOf(org.eclipse.jface.text.IDocument document, long modificationStamp)
-
-