Package org.eclipse.handly.buffer

# 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.

- ## 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 final IBuffer`
  `buffer`
  `protected final 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

  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)`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### buffer

    protected final IBuffer buffer

  - ### change

    protected final IBufferChange change

- ## 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)