Package org.eclipse.handly.ui
Interface IWorkingCopyManager
- All Known Implementing Classes:
SourceFileDocumentProvider
public interface IWorkingCopyManager
Manages the life-cycle of and provides access to working copies of source files. A typical usage pattern is as follows:
final IWorkingCopyManager manager = ...; final IEditorInput input = ...; manager.connect(input); try { ISourceFile workingCopy = manager.getWorkingCopy(input); // workingCopy must not be null at this point ... } finally { manager.disconnect(input); }
Implementations are generally not expected to be thread-safe and, if not mentioned otherwise, may only be called from the user-interface thread.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Connects the given element to this manager.void
disconnect
(Object element) Disconnects the given element from this manager.Returns all working copies that are currently managed by this manager.getWorkingCopy
(Object element) Returns the working copy managed for the given element, ornull
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, ornull
if this manager does not currently manage a working copy for the document.
-
Method Details
-
connect
Connects the given element to this manager. Attempts to acquire a working copy for the given element. Each successful call to this method must ultimately be followed by exactly one matching call todisconnect(Object)
.- Parameters:
element
- notnull
- Throws:
org.eclipse.core.runtime.CoreException
- if the working copy could not be acquired
-
disconnect
Disconnects the given element from this manager. Releases the working copy acquired onconnect(Object)
.- Parameters:
element
- notnull
-
getWorkingCopy
Returns the working copy managed for the given element, ornull
if this manager does not currently manage a working copy for the element.- Parameters:
element
- the element for which to find the working copy, ornull
- Returns:
- the working copy managed for the given element,
or
null
if none
-
getWorkingCopy
Returns the working copy managed for the given document, ornull
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.
- Parameters:
document
- the document for which to find the working copy, ornull
- Returns:
- the working copy managed for the given document,
or
null
if none
-
getWorkingCopies
ISourceFile[] getWorkingCopies()Returns all working copies that are currently managed by this manager.- Returns:
- the working copies currently managed by this manager
(never
null
)
-