1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.core;
13 import org.eclipse.core.resources.IResourceDelta;
16 * A Java element delta describes changes in Java element between two discrete
17 * points in time. Given a delta, clients can access the element that has
18 * changed, and any children that have changed.
20 * Deltas have a different status depending on the kind of change they represent.
21 * The list below summarizes each status (as returned by <code>getKind</code>)
22 * and its meaning (see individual constants for a more detailled description):
24 * <li><code>ADDED</code> - The element described by the delta has been added.</li>
25 * <li><code>REMOVED</code> - The element described by the delta has been removed.</li>
26 * <li><code>CHANGED</code> - The element described by the delta has been changed in some way.
27 * Specification of the type of change is provided by <code>getFlags</code> which returns the following values:
29 * <li><code>F_ADDED_TO_CLASSPATH</code> - A classpath entry corresponding to the element
30 * has been added to the project's classpath. This flag is only valid if the element is an
31 * <code>IPackageFragmentRoot</code>.</li>
32 * <li><code>F_ARCHIVE_CONTENT_CHANGED</code> - The contents of an archive
33 * has changed in some way. This flag is only valid if the element is an <code>IPackageFragmentRoot</code>
34 * which is an archive.</li>
35 * <li><code>F_CHILDREN</code> - A child of the element has changed in some way. This flag
36 * is only valid if the element is an <code>IParent</code>.</li>
37 * <li><code>F_CLASSPATH_REORDER</code> - A classpath entry corresponding to the element
38 * has changed position in the project's classpath. This flag is only valid if the element is an
39 * <code>IPackageFragmentRoot</code>.</li>
40 * <li><code>F_CLOSED</code> - The underlying <code>IProject</code>
41 * has been closed. This flag is only valid if the element is an <code>IJavaProject</code>.</li>
42 * <li><code>F_CONTENT</code> - The contents of the element have been altered. This flag
43 * is only valid for elements which correspond to files.</li>
44 *<li><code>F_FINE_GRAINED</code> - The delta is a fine-grained delta, that is, an analysis down
45 * to the members level was done to determine if there were structural changes to members of the element.</li>
46 * <li><code>F_MODIFIERS</code> - The modifiers on the element have changed in some way.
47 * This flag is only valid if the element is an <code>IMember</code>.</li>
48 * <li><code>F_OPENED</code> - The underlying <code>IProject</code>
49 * has been opened. This flag is only valid if the element is an <code>IJavaProject</code>.</li>
50 * <li><code>F_REMOVED_FROM_CLASSPATH</code> - A classpath entry corresponding to the element
51 * has been removed from the project's classpath. This flag is only valid if the element is an
52 * <code>IPackageFragmentRoot</code>.</li>
53 * <li><code>F_SOURCEATTACHED</code> - The source attachment path or the source attachment root path
54 * of a classpath entry corresponding to the element was added. This flag is only valid if the element is an
55 * <code>IPackageFragmentRoot</code>.</li>
56 * <li><code>F_SOURCEDETACHED</code> - The source attachment path or the source attachment root path
57 * of a classpath entry corresponding to the element was removed. This flag is only valid if the element is an
58 * <code>IPackageFragmentRoot</code>.</li>
59 * <li><code>F_SUPER_TYPES</code> - One of the supertypes of an <code>IType</code> has changed</li>.
65 * Move operations are indicated by other change flags, layered on top
66 * of the change flags described above. If element A is moved to become B,
67 * the delta for the change in A will have status <code>REMOVED</code>,
68 * with change flag <code>F_MOVED_TO</code>. In this case,
69 * <code>getMovedToElement</code> on delta A will return the handle for B.
70 * The delta for B will have status <code>ADDED</code>, with change flag
71 * <code>F_MOVED_FROM</code>, and <code>getMovedFromElement</code> on delta
72 * B will return the handle for A. (Note, the handle to A in this case represents
73 * an element that no longer exists).
76 * Note that the move change flags only describe the changes to a single element, they
77 * do not imply anything about the parent or children of the element.
80 * The <code>F_ADDED_TO_CLASSPATH</code>, <code>F_REMOVED_FROM_CLASSPATH</code> and
81 * <code>F_CLASSPATH_REORDER</code> flags are triggered by changes to a project's classpath. They do not mean that
82 * the underlying resource was added, removed or changed. For example, if a project P already contains a folder src, then
83 * adding a classpath entry with the 'P/src' path to the project's classpath will result in an <code>IJavaElementDelta</code>
84 * with the <code>F_ADDED_TO_CLASSPATH</code> flag for the <code>IPackageFragmentRoot</code> P/src.
85 * On the contrary, if a resource is physically added, removed or changed and this resource corresponds to a classpath
86 * entry of the project, then an <code>IJavaElementDelta</code> with the <code>ADDED</code>,
87 * <code>REMOVED</code>, or <code>CHANGED</code> kind will be fired.
90 * Note that when a source attachment path or a source attachment root path is changed, then the flags of the delta contain
91 * both <code>F_SOURCEATTACHED</code> and <code>F_SOURCEDETTACHED</code>.
94 * No assumptions should be made on whether the java element delta tree is rooted at the <code>IJavaModel</code>
98 * <code>IJavaElementDelta</code> object are not valid outside the dynamic scope
99 * of the notification.
102 * This interface is not intended to be implemented by clients.
105 public interface IJavaElementDelta {
108 * Status constant indicating that the element has been added.
109 * Note that an added java element delta has no children, as they are all implicitely added.
111 public int ADDED = 1;
114 * Status constant indicating that the element has been removed.
115 * Note that a removed java element delta has no children, as they are all implicitely removed.
117 public int REMOVED = 2;
120 * Status constant indicating that the element has been changed,
121 * as described by the change flags.
125 public int CHANGED = 4;
128 * Change flag indicating that the content of the element has changed.
129 * This flag is only valid for elements which correspond to files.
131 public int F_CONTENT = 0x0001;
134 * Change flag indicating that the modifiers of the element have changed.
135 * This flag is only valid if the element is an <code>IMember</code>.
137 public int F_MODIFIERS = 0x0002;
140 * Change flag indicating that there are changes to the children of the element.
141 * This flag is only valid if the element is an <code>IParent</code>.
143 public int F_CHILDREN = 0x0008;
146 * Change flag indicating that the element was moved from another location.
147 * The location of the old element can be retrieved using <code>getMovedFromElement</code>.
149 public int F_MOVED_FROM = 0x0010;
152 * Change flag indicating that the element was moved to another location.
153 * The location of the new element can be retrieved using <code>getMovedToElement</code>.
155 public int F_MOVED_TO = 0x0020;
158 * Change flag indicating that a classpath entry corresponding to the element has been added to the project's classpath.
159 * This flag is only valid if the element is an <code>IPackageFragmentRoot</code>.
161 public int F_ADDED_TO_CLASSPATH = 0x0040;
164 * Change flag indicating that a classpath entry corresponding to the element has been removed from the project's
165 * classpath. This flag is only valid if the element is an <code>IPackageFragmentRoot</code>.
167 public int F_REMOVED_FROM_CLASSPATH = 0x0080;
170 * Change flag indicating that a classpath entry corresponding to the element has changed position in the project's
171 * classpath. This flag is only valid if the element is an <code>IPackageFragmentRoot</code>.
172 * @deprecated Use F_REORDER instead.
174 public int F_CLASSPATH_REORDER = 0x0100;
176 * Change flag indicating that the element has changed position relatively to its siblings.
177 * If the element is an <code>IPackageFragmentRoot</code>, a classpath entry corresponding
178 * to the element has changed position in the project's classpath.
182 public int F_REORDER = 0x0100;
185 * Change flag indicating that the underlying <code>IProject</code> has been
186 * opened. This flag is only valid if the element is an <code>IJavaProject</code>.
188 public int F_OPENED = 0x0200;
191 * Change flag indicating that the underlying <code>IProject</code> has been
192 * closed. This flag is only valid if the element is an <code>IJavaProject</code>.
194 public int F_CLOSED = 0x0400;
197 * Change flag indicating that one of the supertypes of an <code>IType</code>
200 public int F_SUPER_TYPES = 0x0800;
203 * Change flag indicating that the source attachment path or the source attachment root path of a classpath entry
204 * corresponding to the element was added. This flag is only valid if the element is an
205 * <code>IPackageFragmentRoot</code>.
207 public int F_SOURCEATTACHED = 0x1000;
210 * Change flag indicating that the source attachment path or the source attachment root path of a classpath entry
211 * corresponding to the element was removed. This flag is only valid if the element is an
212 * <code>IPackageFragmentRoot</code>.
214 public int F_SOURCEDETACHED = 0x2000;
217 * Change flag indicating that this is a fine-grained delta, that is, an analysis down
218 * to the members level was done to determine if there were structural changes to
221 * Clients can use this flag to find out if a compilation unit
222 * that have a <code>F_CONTENT</code> change should assume that there are
223 * no finer grained changes (<code>F_FINE_GRAINED</code> is set) or if
224 * finer grained changes were not considered (<code>F_FINE_GRAINED</code>
229 public int F_FINE_GRAINED = 0x4000;
232 * Change flag indicating that the element's archive content on the classpath has changed.
233 * This flag is only valid if the element is an <code>IPackageFragmentRoot</code>
234 * which is an archive.
236 * @see IPackageFragmentRoot#isArchive
239 public int F_ARCHIVE_CONTENT_CHANGED = 0x8000;
242 * Returns deltas for the children that have been added.
243 * @return deltas for the children that have been added
245 public IJavaElementDelta[] getAddedChildren();
248 * Returns deltas for the affected (added, removed, or changed) children.
249 * @return deltas for the affected (added, removed, or changed) children
251 public IJavaElementDelta[] getAffectedChildren();
254 * Returns deltas for the children which have changed.
255 * @return deltas for the children which have changed
257 public IJavaElementDelta[] getChangedChildren();
260 * Returns the element that this delta describes a change to.
261 * @return the element that this delta describes a change to
263 public IJavaElement getElement();
266 * Returns flags that describe how an element has changed.
267 * Such flags should be tested using the <code>&</code> operand. For example:
269 * if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) {
270 * // the delta indicates a content change
274 * @return flags that describe how an element has changed
276 public int getFlags();
279 * Returns the kind of this delta - one of <code>ADDED</code>, <code>REMOVED</code>,
280 * or <code>CHANGED</code>.
282 * @return the kind of this delta
284 public int getKind();
287 * Returns an element describing this element before it was moved
288 * to its current location, or <code>null</code> if the
289 * <code>F_MOVED_FROM</code> change flag is not set.
291 * @return an element describing this element before it was moved
292 * to its current location, or <code>null</code> if the
293 * <code>F_MOVED_FROM</code> change flag is not set
295 public IJavaElement getMovedFromElement();
298 * Returns an element describing this element in its new location,
299 * or <code>null</code> if the <code>F_MOVED_TO</code> change
302 * @return an element describing this element in its new location,
303 * or <code>null</code> if the <code>F_MOVED_TO</code> change
306 public IJavaElement getMovedToElement();
309 * Returns deltas for the children which have been removed.
311 * @return deltas for the children which have been removed
313 public IJavaElementDelta[] getRemovedChildren();
316 * Returns the collection of resource deltas.
318 * Note that resource deltas, like Java element deltas, are generally only valid
319 * for the dynamic scope of an event notification. Clients must not hang on to
323 * @return the underlying resource deltas, or <code>null</code> if none
325 public IResourceDelta[] getResourceDeltas();