|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IJavaElementDelta
A Java element delta describes changes in Java element between two discrete points in time. Given a delta, clients can access the element that has changed, and any children that have changed.
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 detailled 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 by getFlags()
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 an
IPackageFragmentRoot
.F_ARCHIVE_CONTENT_CHANGED
- The contents of an archive
has changed in some way. This flag is only valid if the element is an IPackageFragmentRoot
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 an IParent
.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 an
IPackageFragmentRoot
.F_CLOSED
- The underlying IProject
has been closed. This flag is only valid if the element is an IJavaProject
.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 an IMember
.F_OPENED
- The underlying IProject
has been opened. This flag is only valid if the element is an IJavaProject
.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 an
IPackageFragmentRoot
.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 an
IPackageFragmentRoot
.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 an
IPackageFragmentRoot
.F_SUPER_TYPES
- One of the supertypes of an IType
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.
Field Summary | |
---|---|
static int |
ADDED
Status constant indicating that the element has been added. |
static int |
CHANGED
Status constant indicating that the element has been changed, as described by the change flags. |
static int |
F_ADDED_TO_CLASSPATH
Change flag indicating that a classpath entry corresponding to the element has been added to the project's classpath. |
static int |
F_ANNOTATIONS
Change flag indicating that the annotations of the element have changed. |
static int |
F_ARCHIVE_CONTENT_CHANGED
Change flag indicating that the element's archive content on the classpath has changed. |
static int |
F_AST_AFFECTED
Change flag indicating that a reconcile operation has affected the compilation unit AST created in a previous reconcile operation. |
static int |
F_CATEGORIES
Change flag indicating that the categories of the element have changed. |
static int |
F_CHILDREN
Change flag indicating that there are changes to the children of the element. |
static int |
F_CLASSPATH_CHANGED
Change flag indicating that the raw classpath
(or the output folder ) of a project has changed. |
static int |
F_CLASSPATH_REORDER
Deprecated. Use F_REORDER instead. |
static int |
F_CLOSED
Change flag indicating that the underlying IProject has been
closed. |
static int |
F_CONTENT
Change flag indicating that the content of the element has changed. |
static int |
F_FINE_GRAINED
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 int |
F_MODIFIERS
Change flag indicating that the modifiers of the element have changed. |
static int |
F_MOVED_FROM
Change flag indicating that the element was moved from another location. |
static int |
F_MOVED_TO
Change flag indicating that the element was moved to another location. |
static int |
F_OPENED
Change flag indicating that the underlying IProject has been
opened. |
static int |
F_PRIMARY_RESOURCE
Change flag indicating that the resource of a primary compilation unit has changed. |
static int |
F_PRIMARY_WORKING_COPY
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 int |
F_REMOVED_FROM_CLASSPATH
Change flag indicating that a classpath entry corresponding to the element has been removed from the project's classpath. |
static int |
F_REORDER
Change flag indicating that the element has changed position relatively to its siblings. |
static int |
F_RESOLVED_CLASSPATH_CHANGED
Change flag indicating that the resolved classpath of a project has changed. |
static int |
F_SOURCEATTACHED
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 int |
F_SOURCEDETACHED
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 int |
F_SUPER_TYPES
Change flag indicating that one of the supertypes of an IType
has changed. |
static int |
REMOVED
Status constant indicating that the element has been removed. |
Method Summary | |
---|---|
IJavaElementDelta[] |
getAddedChildren()
Returns deltas for the children that have been added. |
IJavaElementDelta[] |
getAffectedChildren()
Returns deltas for the affected (added, removed, or changed) children. |
IJavaElementDelta[] |
getAnnotationDeltas()
Returns deltas for affected annotations (added, removed, or changed). |
IJavaElementDelta[] |
getChangedChildren()
Returns deltas for the children which have changed. |
CompilationUnit |
getCompilationUnitAST()
Returns the compilation unit AST created by the last reconcile operation on this delta's element. |
IJavaElement |
getElement()
Returns the element that this delta describes a change to. |
int |
getFlags()
Returns flags that describe how an element has changed. |
int |
getKind()
Returns the kind of this delta - one of ADDED , REMOVED ,
or CHANGED . |
IJavaElement |
getMovedFromElement()
Returns an element describing this element before it was moved to its current location, or null if the
F_MOVED_FROM change flag is not set. |
IJavaElement |
getMovedToElement()
Returns an element describing this element in its new location, or null if the F_MOVED_TO change
flag is not set. |
IJavaElementDelta[] |
getRemovedChildren()
Returns deltas for the children which have been removed. |
IResourceDelta[] |
getResourceDeltas()
Returns the collection of resource deltas. |
Field Detail |
---|
static final int ADDED
static final int REMOVED
static final int CHANGED
getFlags()
,
Constant Field Valuesstatic final int F_CONTENT
static final int F_MODIFIERS
IMember
.
static final int F_CHILDREN
IParent
.
static final int F_MOVED_FROM
getMovedFromElement()
.
static final int F_MOVED_TO
getMovedToElement()
.
static final int F_ADDED_TO_CLASSPATH
IPackageFragmentRoot
.
static final int F_REMOVED_FROM_CLASSPATH
IPackageFragmentRoot
.
static final int F_CLASSPATH_REORDER
F_REORDER
instead.IPackageFragmentRoot
.
static final int F_REORDER
IPackageFragmentRoot
, a classpath entry corresponding
to the element has changed position in the project's classpath.
static final int F_OPENED
IProject
has been
opened. This flag is only valid if the element is an IJavaProject
.
static final int F_CLOSED
IProject
has been
closed. This flag is only valid if the element is an IJavaProject
.
static final int F_SUPER_TYPES
IType
has changed.
static final int F_SOURCEATTACHED
IPackageFragmentRoot
.
static final int F_SOURCEDETACHED
IPackageFragmentRoot
.
static final int F_FINE_GRAINED
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).
static final int F_ARCHIVE_CONTENT_CHANGED
IPackageFragmentRoot
which is an archive.
IPackageFragmentRoot.isArchive()
,
Constant Field Valuesstatic final int F_PRIMARY_WORKING_COPY
ICompilationUnit
.
static final int F_CLASSPATH_CHANGED
raw classpath
(or the output folder
) of a project has changed.
This flag is only valid if the element is an IJavaProject
.
Also see F_RESOLVED_CLASSPATH_CHANGED
, which indicates that there is a
change to the resolved 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.
static final int F_PRIMARY_RESOURCE
ICompilationUnit
.
static final int F_AST_AFFECTED
getCompilationUnitAST()
to retrieve the AST (if any is available).
This flag is only valid if the element is an ICompilationUnit
in working copy mode.
static final int F_CATEGORIES
IMember
.
static final int F_RESOLVED_CLASSPATH_CHANGED
resolved classpath
of a project has changed.
This flag is only valid if the element is an IJavaProject
.
Also see F_CLASSPATH_CHANGED
, which indicates that there is a
change to the raw 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.
static final int F_ANNOTATIONS
getAnnotationDeltas()
to get the added/removed/changed annotations.
This flag is only valid if the element is an IAnnotatable
.
Method Detail |
---|
IJavaElementDelta[] getAddedChildren()
IJavaElementDelta[] getAffectedChildren()
IJavaElementDelta[] getAnnotationDeltas()
IAnnotatable
.
CompilationUnit getCompilationUnitAST()
ICompilationUnit
in working copy modeElementChangedEvent.POST_RECONCILE
event
ICompilationUnit.reconcile(int, boolean, WorkingCopyOwner, org.eclipse.core.runtime.IProgressMonitor)
,
F_AST_AFFECTED
IJavaElementDelta[] getChangedChildren()
IJavaElement getElement()
int getFlags()
&
operand. For example:
if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) { // the delta indicates a content change }
int getKind()
ADDED
, REMOVED
,
or CHANGED
.
IJavaElement getMovedFromElement()
null
if the
F_MOVED_FROM
change flag is not set.
null
if the
F_MOVED_FROM
change flag is not setIJavaElement getMovedToElement()
null
if the F_MOVED_TO
change
flag is not set.
null
if the F_MOVED_TO
change
flag is not setIJavaElementDelta[] getRemovedChildren()
IResourceDelta[] getResourceDeltas()
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.
null
if none
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |