Class SourceFileDocumentProvider

java.lang.Object
org.eclipse.ui.editors.text.TextFileDocumentProvider
org.eclipse.handly.ui.texteditor.SourceFileDocumentProvider
All Implemented Interfaces:
IWorkingCopyManager, org.eclipse.ui.editors.text.IStorageDocumentProvider, org.eclipse.ui.texteditor.IDocumentProvider, org.eclipse.ui.texteditor.IDocumentProviderExtension, org.eclipse.ui.texteditor.IDocumentProviderExtension2, org.eclipse.ui.texteditor.IDocumentProviderExtension3, org.eclipse.ui.texteditor.IDocumentProviderExtension4, org.eclipse.ui.texteditor.IDocumentProviderExtension5

public abstract class SourceFileDocumentProvider extends org.eclipse.ui.editors.text.TextFileDocumentProvider implements IWorkingCopyManager
Subclass of TextFileDocumentProvider specialized for working copy management of source files.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Subclass of FileInfo that can retain a reference to a working copy of a source file.

    Nested classes/interfaces inherited from class org.eclipse.ui.editors.text.TextFileDocumentProvider

    org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileBufferListener, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo, org.eclipse.ui.editors.text.TextFileDocumentProvider.NullProvider
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new source file document provider with no parent.
    SourceFileDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider parent)
    Creates a new source file document provider with the given parent.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected ISourceFile
    acquireWorkingCopy(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
    Attempts to acquire a working copy for the given element.
    protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo
    protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo
    protected void
    disposeFileInfo(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
    protected abstract ISourceFile
    Returns the source file for the given element.
    Returns all working copies that are currently managed by this manager.
    Returns the working copy managed for the given element, or null if this manager does not currently manage a working copy for the element.
    getWorkingCopy(org.eclipse.jface.text.IDocument document)
    Returns the working copy managed for the given document, or null if this manager does not currently manage a working copy for the document.
    protected void
    releaseWorkingCopy(ISourceFile workingCopy, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
    Releases the given working copy that was acquired via a call to acquireWorkingCopy.

    Methods inherited from class org.eclipse.ui.editors.text.TextFileDocumentProvider

    aboutToChange, addElementStateListener, canSaveDocument, changed, commitFileBuffer, computeSchedulingRule, connect, createAnnotationModel, createFileFromDocument, createSaveOperation, disconnect, executeOperation, fireElementStateChangeFailed, fireElementStateChanging, getAnnotationModel, getConnectedElementsIterator, getContentType, getDefaultEncoding, getDocument, getElements, getEncoding, getFileInfo, getFileInfosIterator, getFileStore, getModificationStamp, getOperationRunner, getParentProvider, getProgressMonitor, getStatus, getSynchronizationStamp, getSystemFile, handleCoreException, isDeleted, isModifiable, isNotSynchronizedException, isReadOnly, isStateValidated, isSynchronized, isSystemFileReadOnly, mustSaveDocument, removeElementStateListener, resetDocument, saveDocument, setCanSaveDocument, setEncoding, setParentDocumentProvider, setProgressMonitor, setUpSynchronization, synchronize, updateStateCache, validateState

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.eclipse.handly.ui.IWorkingCopyManager

    connect, disconnect
  • Constructor Details

    • SourceFileDocumentProvider

      public SourceFileDocumentProvider()
      Creates a new source file document provider with no parent.
    • SourceFileDocumentProvider

      public SourceFileDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider parent)
      Creates a new source file document provider with the given parent.
      Parameters:
      parent - the parent document provider
  • Method Details

    • getWorkingCopy

      public ISourceFile getWorkingCopy(Object element)
      Returns the working copy managed for the given element, or null if this manager does not currently manage a working copy for the element.

      This implementation returns the working copy retained by the file info for the given element. The file info is obtained via TextFileDocumentProvider.getFileInfo(Object).

      Specified by:
      getWorkingCopy in interface IWorkingCopyManager
      Parameters:
      element - the element for which to find the working copy, or null
      Returns:
      the working copy managed for the given element, or null if none
    • getWorkingCopy

      public ISourceFile getWorkingCopy(org.eclipse.jface.text.IDocument document)
      Returns the working copy managed for the given document, or null if this manager does not currently manage a working copy for the document.

      Note: An implementation of this method may go through the list of working copies and test whether the working copy buffer's document equals the given document. Therefore, this method should not be used in performance critical code.

      This implementation returns the working copy retained by the file info for the given document. The file info is found by iterating over this provider's file info objects via TextFileDocumentProvider.getFileInfosIterator() and testing whether the document of the file info's text file buffer equals the given document.

      Specified by:
      getWorkingCopy in interface IWorkingCopyManager
      Parameters:
      document - the document for which to find the working copy, or null
      Returns:
      the working copy managed for the given document, or null if none
    • getWorkingCopies

      public ISourceFile[] getWorkingCopies()
      Returns all working copies that are currently managed by this manager.

      This implementation iterates over this provider's file info objects via TextFileDocumentProvider.getFileInfosIterator() and collects the working copies they retain.

      Specified by:
      getWorkingCopies in interface IWorkingCopyManager
      Returns:
      the working copies currently managed by this manager (never null)
    • getSourceFile

      protected abstract ISourceFile getSourceFile(Object element)
      Returns the source file for the given element.
      Parameters:
      element - the element
      Returns:
      the source file for the given element, or null if none
    • createEmptyFileInfo

      protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createEmptyFileInfo()

      This implementation returns a new instance of SourceFileInfo.

      Overrides:
      createEmptyFileInfo in class org.eclipse.ui.editors.text.TextFileDocumentProvider
    • createFileInfo

      protected org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo createFileInfo(Object element) throws org.eclipse.core.runtime.CoreException

      This implementation invokes the superclass implementation to create the file info object. It then attempts to acquire a working copy for the given element if the created object is an instance of SourceFileInfo and, if successful, stores a reference to the acquired working copy in the created file info.

      Overrides:
      createFileInfo in class org.eclipse.ui.editors.text.TextFileDocumentProvider
      Throws:
      org.eclipse.core.runtime.CoreException
    • disposeFileInfo

      protected void disposeFileInfo(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)

      This implementation invokes the superclass implementation after trying to release the working copy retained by the given file info object.

      Overrides:
      disposeFileInfo in class org.eclipse.ui.editors.text.TextFileDocumentProvider
    • acquireWorkingCopy

      protected ISourceFile acquireWorkingCopy(Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info) throws org.eclipse.core.runtime.CoreException
      Attempts to acquire a working copy for the given element. A working copy acquired by this method must be released eventually via a call to releaseWorkingCopy.

      This implementation obtains a source file for the given element via getSourceFile(Object) and, if the source file implements ISourceFileImplExtension, invokes becomeWorkingCopy_(EMPTY_CONTEXT, null) on it and returns the acquired working copy. Otherwise, null is returned.

      Parameters:
      element - the element
      info - the element info
      Returns:
      the acquired working copy, or null if no working copy can be acquired for the given element
      Throws:
      org.eclipse.core.runtime.CoreException - if the working copy could not be acquired successfully
    • releaseWorkingCopy

      protected void releaseWorkingCopy(ISourceFile workingCopy, Object element, org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo info)
      Releases the given working copy that was acquired via a call to acquireWorkingCopy.

      This implementation invokes ((ISourceFileImplExtension)workingCopy).releaseWorkingCopy_().

      Parameters:
      workingCopy - the working copy to release
      element - the element
      info - the element info