Class BufferChangeOperation

java.lang.Object
org.eclipse.handly.buffer.BufferChangeOperation

public class BufferChangeOperation extends Object
Applies a given change to a given IBuffer. This class is intended to be used in implementations of IBuffer. General clients should use IBuffer.applyChange(IBufferChange, IProgressMonitor) instead.
  • Field Details

  • Constructor Details

    • 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 be null
      change - must not be null
  • Method Details

    • 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 (not null). The caller must not rely on IProgressMonitor.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 based
      org.eclipse.core.runtime.CoreException - if save is requested by the change but the buffer could not be saved
      org.eclipse.text.edits.MalformedTreeException - if the change's edit tree is not in a valid state
      org.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)