|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ICompilationUnit
instead
public interface IWorkingCopy
Common protocol for Java elements that support working copies.
A working copy of a Java element acts just like a regular element (handle), except it is not attached to an underlying resource. A working copy is not visible to the rest of the Java model. Changes in a working copy's buffer are not realized in a resource. To bring the Java model up-to-date with a working copy's contents, an explicit commit must be performed on the working copy. Other operations performed on a working copy update the contents of the working copy's buffer but do not commit the contents of the working copy.
Note: The contents of a working copy is determined when a working
copy is created, based on the current content of the element the working
copy is created from. If a working copy is an IOpenable
and is explicitly
closed, the working copy's buffer will be thrown away. However, clients should not
explicitly open and close working copies.
The client that creates a working copy is responsible for
destroying the working copy. The Java model will never automatically
destroy or close a working copy. (Note that destroying a working copy
does not commit it to the model, it only frees up the memory occupied by
the element). After a working copy is destroyed, the working copy cannot
be accessed again. Non-handle methods will throw a
JavaModelException
indicating the Java element does not exist.
A working copy cannot be created from another working copy.
Calling getWorkingCopy
on a working copy returns the receiver.
Method Detail |
---|
void commit(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ICompilationUnit.commitWorkingCopy(boolean, IProgressMonitor)
instead.
It is possible that the contents of the original resource have changed
since this working copy was created, in which case there is an update conflict.
The value of the force
parameter effects the resolution of
such a conflict:
true
- in this case the contents of this working copy are applied to
the underlying resource even though this working copy was created before
a subsequent change in the resourcefalse
- in this case a JavaModelException
is thrownSince 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
force
- a flag to handle the cases when the contents of the original resource have changed
since this working copy was createdmonitor
- the given progress monitor
JavaModelException
- if this working copy could not commit. Reasons include:
CoreException
occurred while updating an underlying resource
void destroy()
ICompilationUnit.discardWorkingCopy()
instead.
IJavaModelException
s. Has
no effect if this element is not a working copy.
If this working copy is shared, it is destroyed only when the number of calls to
destroy()
is the same as the number of calls to
getSharedWorkingCopy(IProgressMonitor, IBufferFactory)
.
When it is destroyed, a REMOVED IJavaElementDelta is reported on this working copy.
IJavaElement findSharedWorkingCopy(IBufferFactory bufferFactory)
ICompilationUnit.findWorkingCopy(WorkingCopyOwner)
instead.
IBuffer
factory.
If no working copy has been created for this element associated with this
buffer factory, returns null
.
Users of this method must not destroy the resulting working copy.
bufferFactory
- the given IBuffer
factory
null
if noneIBufferFactory
IJavaElement getOriginal(IJavaElement workingCopyElement)
IJavaElement.getPrimaryElement()
instead.
null
if this is not a working copy element. This is a handle
only method, the returned element may or may not exist.
workingCopyElement
- the specified working copy element
null
if this is not a working copy elementIJavaElement getOriginalElement()
IJavaElement.getPrimaryElement()
instead.
null
if this is not a working copy.
null
if this is not a working copyIJavaElement[] findElements(IJavaElement element)
ICompilationUnit.findElements(IJavaElement)
instead.
null
if no such java elements can be found
or if the given element is not included in a compilation unit.
element
- the given element
IType findPrimaryType()
ITypeRoot.findPrimaryType()
instead.
null
if no such a type exists.
null
if no such a type existsIJavaElement getSharedWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException
ICompilationUnit.getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
instead.
Object.equals
).
The life time of a shared working copy is as follows:
getSharedWorkingCopy(...)
creates a new working copy for this
elementdestroy()
decrements the internal counter.Note that the buffer factory will be used for the life time of this working copy, that is if the working copy is closed then reopened, this factory will be used. The buffer will be automatically initialized with the original's compilation unit content upon creation.
When the shared working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
monitor
- a progress monitor used to report progress while opening this compilation unit
or null
if no progress should be reportedfactory
- the factory that creates a buffer that is used to get the content of the working copy
or null
if the internal factory should be usedproblemRequestor
- a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null
indicating
that the client is not interested in problems.
JavaModelException
- if the contents of this element can
not be determined.IBufferFactory
,
IProblemRequestor
IJavaElement getWorkingCopy() throws JavaModelException
ICompilationUnit.getWorkingCopy(IProgressMonitor)
instead.
Note: if intending to share a working copy amongst several clients, then
#getSharedWorkingCopy
should be used instead.
When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
JavaModelException
- if the contents of this element can
not be determined.IJavaElement getWorkingCopy(org.eclipse.core.runtime.IProgressMonitor monitor, IBufferFactory factory, IProblemRequestor problemRequestor) throws JavaModelException
ICompilationUnit.getWorkingCopy(WorkingCopyOwner, IProblemRequestor, IProgressMonitor)
instead.
Note: if intending to share a working copy amongst several clients, then
#getSharedWorkingCopy
should be used instead.
When the working copy instance is created, an ADDED IJavaElementDelta is reported on this working copy.
Since 2.1, a working copy can be created on a not-yet existing compilation unit. In particular, such a working copy can then be committed in order to create the corresponding compilation unit.
monitor
- a progress monitor used to report progress while opening this compilation unit
or null
if no progress should be reportedfactory
- the factory that creates a buffer that is used to get the content of the working copy
or null
if the internal factory should be usedproblemRequestor
- a requestor which will get notified of problems detected during
reconciling as they are discovered. The requestor can be set to null
indicating
that the client is not interested in problems.
JavaModelException
- if the contents of this element can
not be determined.boolean isBasedOn(IResource resource)
ICompilationUnit.hasResourceChanged()
instead.
resource
- this working copy's resource
boolean isWorkingCopy()
ICompilationUnit.isWorkingCopy()
instead.
IMarker[] reconcile() throws JavaModelException
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
instead.
If the working copy hasn't changed, then no problem will be detected,
this is equivalent to IWorkingCopy#reconcile(false, null)
.
Compilation problems found in the new contents are notified through the
IProblemRequestor
interface which was passed at
creation, and no longer as transient markers. Therefore this API will
return null
.
Note: Since 3.0 added/removed/changed inner types generate change deltas.
null
JavaModelException
- if the contents of the original element
cannot be accessed. Reasons include:
void reconcile(boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor) throws JavaModelException
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, IProgressMonitor)
instead.
The boolean argument allows to force problem detection even if the working copy is already consistent.
Compilation problems found in the new contents are notified through the
IProblemRequestor
interface which was passed at
creation, and no longer as transient markers. Therefore this API answers
nothing.
Note: Since 3.0 added/removed/changed inner types generate change deltas.
forceProblemDetection
- boolean indicating whether problem should be recomputed
even if the source hasn't changed.monitor
- a progress monitor
JavaModelException
- if the contents of the original element
cannot be accessed. Reasons include:
void restore() throws JavaModelException
ICompilationUnit.restore()
instead.
Note: This is the inverse of committing the content of the
working copy to the original element with commit(boolean, IProgressMonitor)
.
JavaModelException
- if the contents of the original element
cannot be accessed. Reasons include:
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |