Interface IWorkingCopy
-
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable
,IBufferChangedListener
,ICElement
,IOpenable
,IParent
,ISourceManipulation
,ISourceReference
,ITranslationUnit
public interface IWorkingCopy extends ITranslationUnit
A working copy of a C 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 C model. Changes in a working copy's buffer are not realized in a resource. To bring the C 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
ICFile
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 C 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
CModelException
indicating the C element does not exist.A working copy cannot be created from another working copy. Calling
getWorkingCopy
on a working copy returns the receiver.- Restriction:
- This interface is not intended to be implemented by clients.
- Restriction:
- This interface is not intended to be extended by clients.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.cdt.core.model.ICElement
ASM_LABEL, C_ARCHIVE, C_BINARY, C_CCONTAINER, C_CLASS, C_CLASS_CTOR, C_CLASS_DECLARATION, C_CLASS_DTOR, C_ENUMERATION, C_ENUMERATOR, C_FIELD, C_FUNCTION, C_FUNCTION_DECLARATION, C_INCLUDE, C_MACRO, C_METHOD, C_METHOD_DECLARATION, C_MODEL, C_NAMESPACE, C_PRAGMA, C_PROJECT, C_STORAGE_EXTERN, C_STORAGE_STATIC, C_STRUCT, C_STRUCT_DECLARATION, C_TEMPLATE_CLASS, C_TEMPLATE_CLASS_DECLARATION, C_TEMPLATE_FUNCTION, C_TEMPLATE_FUNCTION_DECLARATION, C_TEMPLATE_METHOD, C_TEMPLATE_METHOD_DECLARATION, C_TEMPLATE_STRUCT, C_TEMPLATE_STRUCT_DECLARATION, C_TEMPLATE_UNION, C_TEMPLATE_UNION_DECLARATION, C_TEMPLATE_VARIABLE, C_TYPEDEF, C_UNION, C_UNION_DECLARATION, C_UNIT, C_UNKNOWN_DECLARATION, C_USING, C_VARIABLE, C_VARIABLE_DECLARATION, C_VARIABLE_LOCAL, C_VCONTAINER, CPP_FRIEND, CPP_PRIVATE, CPP_PROTECTED, CPP_PUBLIC, EMPTY_ARRAY
-
Fields inherited from interface org.eclipse.cdt.core.model.ITranslationUnit
AST_CONFIGURE_USING_SOURCE_CONTEXT, AST_CREATE_COMMENT_NODES, AST_PARSE_INACTIVE_CODE, AST_SKIP_ALL_HEADERS, AST_SKIP_FUNCTION_BODIES, AST_SKIP_IF_NO_BUILD_INFO, AST_SKIP_INDEXED_HEADERS, AST_SKIP_NONINDEXED_HEADERS, AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
commit(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor)
Commits the contents of this working copy to its original element and underlying resource, bringing the C model up-to-date with the current contents of the working copy.void
destroy()
Destroys this working copy, closing its buffer and discarding its structure.ICElement
getOriginal(ICElement workingCopyElement)
Returns the original element the specified working copy element was created from, ornull
if this is not a working copy element.ITranslationUnit
getOriginalElement()
Returns the original element this working copy was created from, ornull
if this is not a working copy.boolean
isBasedOn(org.eclipse.core.resources.IResource resource)
Returns whether this working copy's original element's content has not changed since the inception of this working copy.org.eclipse.core.resources.IMarker[]
reconcile()
Reconciles the contents of this working copy.IASTTranslationUnit
reconcile(boolean computeAST, boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy.void
reconcile(boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor)
Reconciles the contents of this working copy.void
restore()
Restores the contents of this working copy to the current contents of this working copy's original element.-
Methods inherited from interface org.eclipse.cdt.core.model.IBufferChangedListener
bufferChanged
-
Methods inherited from interface org.eclipse.cdt.core.model.ICElement
accept, exists, getAncestor, getCModel, getCProject, getElementName, getElementType, getHandleIdentifier, getLocationURI, getParent, getPath, getResource, getUnderlyingResource, isReadOnly, isStructureKnown
-
Methods inherited from interface org.eclipse.cdt.core.model.IOpenable
close, getBuffer, hasUnsavedChanges, isConsistent, isOpen, makeConsistent, makeConsistent, open, save
-
Methods inherited from interface org.eclipse.cdt.core.model.IParent
getChildren, getChildrenOfType, hasChildren
-
Methods inherited from interface org.eclipse.cdt.core.model.ISourceManipulation
copy, delete, move, rename
-
Methods inherited from interface org.eclipse.cdt.core.model.ISourceReference
getIndex, getSource, getSourceRange, getTranslationUnit, isActive
-
Methods inherited from interface org.eclipse.cdt.core.model.ITranslationUnit
createInclude, createNamespace, createUsing, findSharedWorkingCopy, findSharedWorkingCopy, getAST, getAST, getCodeReader, getCompletionNode, getContents, getContentTypeId, getElement, getElementAtLine, getElementAtOffset, getElementsAtOffset, getFile, getInclude, getIncludes, getLanguage, getLocation, getNamespace, getNamespaces, getScannerInfo, getSharedWorkingCopy, getSharedWorkingCopy, getSharedWorkingCopy, getUsing, getUsings, getWorkingCopy, getWorkingCopy, getWorkingCopy, isASMLanguage, isCLanguage, isCXXLanguage, isHeaderUnit, isSourceUnit, isWorkingCopy, parse, setIsStructureKnown
-
-
-
-
Method Detail
-
commit
void commit(boolean force, org.eclipse.core.runtime.IProgressMonitor monitor) throws CModelException
Commits the contents of this working copy to its original element and underlying resource, bringing the C model up-to-date with the current contents of the working copy.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 resource -
false
- in this case aCModelException
is thrown
- Throws:
CModelException
-
-
destroy
void destroy()
Destroys this working copy, closing its buffer and discarding its structure. Subsequent attempts to access non-handle information for this working copy will result inCModelException
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 togetSharedWorkingCopy(IProgressMonitor, IBufferFactory)
. A REMOVED CElementDelta is then reported on this working copy.
-
getOriginal
ICElement getOriginal(ICElement workingCopyElement)
Returns the original element the specified working copy element was created from, ornull
if this is not a working copy element.- Parameters:
workingCopyElement
- the specified working copy element- Returns:
- the original element the specified working copy element was created from,
or
null
if this is not a working copy element
-
getOriginalElement
ITranslationUnit getOriginalElement()
Returns the original element this working copy was created from, ornull
if this is not a working copy.
-
isBasedOn
boolean isBasedOn(org.eclipse.core.resources.IResource resource)
Returns whether this working copy's original element's content has not changed since the inception of this working copy.- Returns:
- true if this working copy's original element's content has not changed since the inception of this working copy, false otherwise
-
reconcile
org.eclipse.core.resources.IMarker[] reconcile() throws CModelException
Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.If the working copy hasn't changed, then no problem will be detected, this is equivalent to
IWorkingCopy#reconcile(false, null)
.- Throws:
CModelException
-
reconcile
void reconcile(boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor) throws CModelException
Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.- Parameters:
forceProblemDetection
- The boolean argument allows to force problem detection even if the working copy is already consistent.monitor
- a progress monitor- Throws:
CModelException
- if the contents of the original element cannot be accessed
-
reconcile
IASTTranslationUnit reconcile(boolean computeAST, boolean forceProblemDetection, org.eclipse.core.runtime.IProgressMonitor monitor) throws CModelException
Reconciles the contents of this working copy. It performs the reconciliation by locally caching the contents of the working copy, updating the contents, then creating a delta over the cached contents and the new contents, and finally firing this delta.The boolean argument allows to force problem detection even if the working copy is already consistent.
EXPERIMENTAL. This method has been added as part of a work in progress. There is no guarantee that this API will work or that it will remain the same. Please do not use this API without consulting with the CDT team.
- Parameters:
computeAST
- flag to indicate if an AST should be returnedforceProblemDetection
- The boolean argument allows to force problem detection even if the working copy is already consistent.monitor
- a progress monitor- Returns:
- the AST or
null
- Throws:
CModelException
- if the contents of the original element cannot be accessed- Since:
- 4.0
-
restore
void restore() throws CModelException
Restores the contents of this working copy to the current contents of this working copy's original element. Has no effect if this element is not a working copy.- Throws:
CModelException
-
-