Interface IJavaElementDelta
Deltas have a different status depending on the kind of change they represent.
The list below summarizes each status (as returned by getKind()
)
and its meaning (see individual constants for a more detailed description):
ADDED
- The element described by the delta has been added.REMOVED
- The element described by the delta has been removed.CHANGED
- The element described by the delta has been changed in some way. Specification of the type of change is provided bygetFlags()
which returns the following values:F_ADDED_TO_CLASSPATH
- A classpath entry corresponding to the element has been added to the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.F_ARCHIVE_CONTENT_CHANGED
- The contents of an archive has changed in some way. This flag is only valid if the element is anIPackageFragmentRoot
which is an archive.F_CHILDREN
- A child of the element has changed in some way. This flag is only valid if the element is anIParent
.F_CLASSPATH_REORDER
- A classpath entry corresponding to the element has changed position in the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.F_CLOSED
- The underlyingIProject
has been closed. This flag is only valid if the element is anIJavaProject
.F_CONTENT
- The contents of the element have been altered. This flag is only valid for elements which correspond to files.F_FINE_GRAINED
- The delta is a fine-grained delta, that is, an analysis down to the members level was done to determine if there were structural changes to members of the element.F_MODIFIERS
- The modifiers on the element have changed in some way. This flag is only valid if the element is anIMember
.F_OPENED
- The underlyingIProject
has been opened. This flag is only valid if the element is anIJavaProject
.F_REMOVED_FROM_CLASSPATH
- A classpath entry corresponding to the element has been removed from the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.F_SOURCEATTACHED
- The source attachment path or the source attachment root path of a classpath entry corresponding to the element was added. This flag is only valid if the element is anIPackageFragmentRoot
.F_SOURCEDETACHED
- The source attachment path or the source attachment root path of a classpath entry corresponding to the element was removed. This flag is only valid if the element is anIPackageFragmentRoot
.F_SUPER_TYPES
- One of the supertypes of anIType
has changed.
Move operations are indicated by other change flags, layered on top
of the change flags described above. If element A is moved to become B,
the delta for the change in A will have status REMOVED
,
with change flag F_MOVED_TO
. In this case,
getMovedToElement()
on delta A will return the handle for B.
The delta for B will have status ADDED
, with change flag
F_MOVED_FROM
, and getMovedFromElement()
on delta
B will return the handle for A. (Note, the handle to A in this case represents
an element that no longer exists).
Note that the move change flags only describe the changes to a single element, they do not imply anything about the parent or children of the element.
The F_ADDED_TO_CLASSPATH
, F_REMOVED_FROM_CLASSPATH
and
F_CLASSPATH_REORDER
flags are triggered by changes to a project's classpath. They do not mean that
the underlying resource was added, removed or changed. For example, if a project P already contains a folder src, then
adding a classpath entry with the 'P/src' path to the project's classpath will result in an IJavaElementDelta
with the F_ADDED_TO_CLASSPATH
flag for the IPackageFragmentRoot
P/src.
On the contrary, if a resource is physically added, removed or changed and this resource corresponds to a classpath
entry of the project, then an IJavaElementDelta
with the ADDED
,
REMOVED
, or CHANGED
kind will be fired.
Note that when a source attachment path or a source attachment root path is changed, then the flags of the delta contain
both F_SOURCEATTACHED
and F_SOURCEDETACHED
.
No assumptions should be made on whether the java element delta tree is rooted at the IJavaModel
level or not.
IJavaElementDelta
object are not valid outside the dynamic scope
of the notification.
- See Also:
- Restriction:
- This interface is not intended to be implemented by clients.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Status constant indicating that the element has been added.static final int
Status constant indicating that the element has been changed, as described by the change flags.static final int
Change flag indicating that a classpath entry corresponding to the element has been added to the project's classpath.static final int
Change flag indicating that the annotations of the element have changed.static final int
Change flag indicating that the element's archive content on the classpath has changed.static final int
Change flag indicating that a reconcile operation has affected the compilation unit AST created in a previous reconcile operation.static final int
Change flag indicating that the categories of the element have changed.static final int
Change flag indicating that there are changes to the children of the element.static final int
Change flag indicating that the attributes of the element have changed.static final int
Change flag indicating that theraw classpath
(or theoutput folder
) of a project has changed.static final int
Deprecated.static final int
Change flag indicating that the underlyingIProject
has been closed.static final int
Change flag indicating that the content of the element has changed.static final int
Change flag indicating that this is a fine-grained delta, that is, an analysis down to the members level was done to determine if there were structural changes to members.static final int
Change flag indicating that the modifiers of the element have changed.static final int
Change flag indicating that the element was moved from another location.static final int
Change flag indicating that the element was moved to another location.static final int
Change flag indicating that the underlyingIProject
has been opened.static final int
Change flag indicating that the resource of a primary compilation unit has changed.static final int
Change flag indicating that a compilation unit has become a primary working copy, or that a primary working copy has reverted to a compilation unit.static final int
Change flag indicating that a classpath entry corresponding to the element has been removed from the project's classpath.static final int
Change flag indicating that the element has changed position relatively to its siblings.static final int
Change flag indicating that theresolved classpath
of a project has changed.static final int
Change flag indicating that the source attachment path or the source attachment root path of a classpath entry corresponding to the element was added.static final int
Change flag indicating that the source attachment path or the source attachment root path of a classpath entry corresponding to the element was removed.static final int
Change flag indicating that one of the supertypes of anIType
has changed.static final int
Status constant indicating that the element has been removed. -
Method Summary
Modifier and TypeMethodDescriptionReturns deltas for the children that have been added.Returns deltas for the affected (added, removed, or changed) children.Returns deltas for affected annotations (added, removed, or changed).Returns deltas for the children which have changed.default IClasspathAttributeDelta[]
Returns deltas for affected attributes (added, removed, or changed).Returns the compilation unit AST created by the last reconcile operation on this delta's element.Returns the element that this delta describes a change to.int
getFlags()
Returns flags that describe how an element has changed.int
getKind()
Returns an element describing this element before it was moved to its current location, ornull
if theF_MOVED_FROM
change flag is not set.Returns an element describing this element in its new location, ornull
if theF_MOVED_TO
change flag is not set.Returns deltas for the children which have been removed.org.eclipse.core.resources.IResourceDelta[]
Returns the collection of resource deltas.
-
Field Details
-
ADDED
static final int ADDEDStatus constant indicating that the element has been added. Note that an added java element delta has no children, as they are all implicitely added.- See Also:
-
REMOVED
static final int REMOVEDStatus constant indicating that the element has been removed. Note that a removed java element delta has no children, as they are all implicitely removed.- See Also:
-
CHANGED
static final int CHANGEDStatus constant indicating that the element has been changed, as described by the change flags.- See Also:
-
F_CONTENT
static final int F_CONTENTChange flag indicating that the content of the element has changed. This flag is only valid for elements which correspond to files.- See Also:
-
F_MODIFIERS
static final int F_MODIFIERSChange flag indicating that the modifiers of the element have changed. This flag is only valid if the element is anIMember
.- See Also:
-
F_CHILDREN
static final int F_CHILDRENChange flag indicating that there are changes to the children of the element. This flag is only valid if the element is anIParent
.- See Also:
-
F_MOVED_FROM
static final int F_MOVED_FROMChange flag indicating that the element was moved from another location. The location of the old element can be retrieved usinggetMovedFromElement()
.- See Also:
-
F_MOVED_TO
static final int F_MOVED_TOChange flag indicating that the element was moved to another location. The location of the new element can be retrieved usinggetMovedToElement()
.- See Also:
-
F_ADDED_TO_CLASSPATH
static final int F_ADDED_TO_CLASSPATHChange flag indicating that a classpath entry corresponding to the element has been added to the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.- See Also:
-
F_REMOVED_FROM_CLASSPATH
static final int F_REMOVED_FROM_CLASSPATHChange flag indicating that a classpath entry corresponding to the element has been removed from the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.- See Also:
-
F_CLASSPATH_REORDER
static final int F_CLASSPATH_REORDERDeprecated.UseF_REORDER
instead.Change flag indicating that a classpath entry corresponding to the element has changed position in the project's classpath. This flag is only valid if the element is anIPackageFragmentRoot
.- See Also:
-
F_REORDER
static final int F_REORDERChange flag indicating that the element has changed position relatively to its siblings. If the element is anIPackageFragmentRoot
, a classpath entry corresponding to the element has changed position in the project's classpath.- Since:
- 2.1
- See Also:
-
F_OPENED
static final int F_OPENEDChange flag indicating that the underlyingIProject
has been opened. This flag is only valid if the element is anIJavaProject
.- See Also:
-
F_CLOSED
static final int F_CLOSEDChange flag indicating that the underlyingIProject
has been closed. This flag is only valid if the element is anIJavaProject
.- See Also:
-
F_SUPER_TYPES
static final int F_SUPER_TYPESChange flag indicating that one of the supertypes of anIType
has changed.- See Also:
-
F_SOURCEATTACHED
static final int F_SOURCEATTACHEDChange flag indicating that the source attachment path or the source attachment root path of a classpath entry corresponding to the element was added. This flag is only valid if the element is anIPackageFragmentRoot
.- See Also:
-
F_SOURCEDETACHED
static final int F_SOURCEDETACHEDChange flag indicating that the source attachment path or the source attachment root path of a classpath entry corresponding to the element was removed. This flag is only valid if the element is anIPackageFragmentRoot
.- See Also:
-
F_FINE_GRAINED
static final int F_FINE_GRAINEDChange flag indicating that this is a fine-grained delta, that is, an analysis down to the members level was done to determine if there were structural changes to members.Clients can use this flag to find out if a compilation unit that have a
F_CONTENT
change should assume that there are no finer grained changes (F_FINE_GRAINED
is set) or if finer grained changes were not considered (F_FINE_GRAINED
is not set).- Since:
- 2.0
- See Also:
-
F_ARCHIVE_CONTENT_CHANGED
static final int F_ARCHIVE_CONTENT_CHANGEDChange flag indicating that the element's archive content on the classpath has changed. This flag is only valid if the element is anIPackageFragmentRoot
which is an archive.- Since:
- 2.0
- See Also:
-
F_PRIMARY_WORKING_COPY
static final int F_PRIMARY_WORKING_COPYChange flag indicating that a compilation unit has become a primary working copy, or that a primary working copy has reverted to a compilation unit. This flag is only valid if the element is anICompilationUnit
.- Since:
- 3.0
- See Also:
-
F_CLASSPATH_CHANGED
static final int F_CLASSPATH_CHANGEDChange flag indicating that theraw classpath
(or theoutput folder
) of a project has changed. This flag is only valid if the element is anIJavaProject
. Also seeF_RESOLVED_CLASSPATH_CHANGED
, which indicates that there is a change to theresolved class path
. The resolved classpath can change without the raw classpath changing (e.g. if a container resolves to a different set of classpath entries). And conversely, it is possible to construct a case where the raw classpath can change without the resolved classpath changing.- Since:
- 3.0
- See Also:
-
F_PRIMARY_RESOURCE
static final int F_PRIMARY_RESOURCEChange flag indicating that the resource of a primary compilation unit has changed. This flag is only valid if the element is a primaryICompilationUnit
.- Since:
- 3.0
- See Also:
-
F_AST_AFFECTED
static final int F_AST_AFFECTEDChange flag indicating that a reconcile operation has affected the compilation unit AST created in a previous reconcile operation. UsegetCompilationUnitAST()
to retrieve the AST (if any is available). This flag is only valid if the element is anICompilationUnit
in working copy mode.- Since:
- 3.2
- See Also:
-
F_CATEGORIES
static final int F_CATEGORIESChange flag indicating that the categories of the element have changed. This flag is only valid if the element is anIMember
.- Since:
- 3.2
- See Also:
-
F_RESOLVED_CLASSPATH_CHANGED
static final int F_RESOLVED_CLASSPATH_CHANGEDChange flag indicating that theresolved classpath
of a project has changed. This flag is only valid if the element is anIJavaProject
. Also seeF_CLASSPATH_CHANGED
, which indicates that there is a change to theraw class path
. The resolved classpath can change without the raw classpath changing (e.g. if a container resolves to a different set of classpath entries). And conversely, it is possible to construct a case where the raw classpath can change without the resolved classpath changing.- Since:
- 3.4
- See Also:
-
F_ANNOTATIONS
static final int F_ANNOTATIONSChange flag indicating that the annotations of the element have changed. UsegetAnnotationDeltas()
to get the added/removed/changed annotations. This flag is only valid if the element is anIAnnotatable
.- Since:
- 3.4
- See Also:
-
F_CLASSPATH_ATTRIBUTES
static final int F_CLASSPATH_ATTRIBUTESChange flag indicating that the attributes of the element have changed. UsegetClasspathAttributeDeltas()
to get the added/removed/changed attributes.- Since:
- 3.33
- See Also:
-
-
Method Details
-
getAddedChildren
IJavaElementDelta[] getAddedChildren()Returns deltas for the children that have been added.- Returns:
- deltas for the children that have been added
-
getAffectedChildren
IJavaElementDelta[] getAffectedChildren()Returns deltas for the affected (added, removed, or changed) children.- Returns:
- deltas for the affected (added, removed, or changed) children
-
getAnnotationDeltas
IJavaElementDelta[] getAnnotationDeltas()Returns deltas for affected annotations (added, removed, or changed). Returns an empty array if no annotations was affected, or if this delta's element is not anIAnnotatable
.- Returns:
- deltas for affected annotations (added, removed, or changed)
- Since:
- 3.4
-
getCompilationUnitAST
CompilationUnit getCompilationUnitAST()Returns the compilation unit AST created by the last reconcile operation on this delta's element. This returns a non-null value if and only if:- the last reconcile operation on this working copy requested an AST
- this delta's element is an
ICompilationUnit
in working copy mode - the delta comes from a
ElementChangedEvent.POST_RECONCILE
event
- Returns:
- the AST created during the last reconcile operation
- Since:
- 3.2
- See Also:
-
getChangedChildren
IJavaElementDelta[] getChangedChildren()Returns deltas for the children which have changed.- Returns:
- deltas for the children which have changed
-
getElement
IJavaElement getElement()Returns the element that this delta describes a change to.- Returns:
- the element that this delta describes a change to
-
getFlags
int getFlags()Returns flags that describe how an element has changed. Such flags should be tested using the&
operand. For example:if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) { // the delta indicates a content change }
- Returns:
- flags that describe how an element has changed
-
getKind
int getKind()- Returns:
- the kind of this delta
-
getMovedFromElement
IJavaElement getMovedFromElement()Returns an element describing this element before it was moved to its current location, ornull
if theF_MOVED_FROM
change flag is not set.- Returns:
- an element describing this element before it was moved
to its current location, or
null
if theF_MOVED_FROM
change flag is not set
-
getMovedToElement
IJavaElement getMovedToElement()Returns an element describing this element in its new location, ornull
if theF_MOVED_TO
change flag is not set.- Returns:
- an element describing this element in its new location,
or
null
if theF_MOVED_TO
change flag is not set
-
getRemovedChildren
IJavaElementDelta[] getRemovedChildren()Returns deltas for the children which have been removed.- Returns:
- deltas for the children which have been removed
-
getResourceDeltas
org.eclipse.core.resources.IResourceDelta[] getResourceDeltas()Returns the collection of resource deltas.Note that resource deltas, like Java element deltas, are generally only valid for the dynamic scope of an event notification. Clients must not hang on to these objects.
- Returns:
- the underlying resource deltas, or
null
if none
-
getClasspathAttributeDeltas
Returns deltas for affected attributes (added, removed, or changed). Returns an empty array if no attribute was affected, or if this delta's element is not for an affectedIClasspathEntry
.- Returns:
- deltas for affected attributes (added, removed, or changed)
- Since:
- 3.33
-
F_REORDER
instead.