KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > JavaElementDelta


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.core;
12
13 import java.util.ArrayList JavaDoc;
14
15 import org.eclipse.core.resources.IResourceDelta;
16 import org.eclipse.jdt.core.IJavaElement;
17 import org.eclipse.jdt.core.IJavaElementDelta;
18 import org.eclipse.jdt.core.dom.CompilationUnit;
19
20 /**
21  * @see IJavaElementDelta
22  */

23 public class JavaElementDelta extends SimpleDelta implements IJavaElementDelta {
24     /**
25      * @see #getAffectedChildren()
26      */

27     protected IJavaElementDelta[] affectedChildren = EMPTY_DELTA;
28     
29     /*
30      * The AST created during the last reconcile operation.
31      * Non-null only iff:
32      * - in a POST_RECONCILE event
33      * - an AST was requested during the last reconcile operation
34      * - the changed element is an ICompilationUnit in working copy mode
35      */

36     protected CompilationUnit ast = null;
37
38     /*
39      * The element that this delta describes the change to.
40      */

41     protected IJavaElement changedElement;
42     
43     /**
44      * Collection of resource deltas that correspond to non java resources deltas.
45      */

46     protected IResourceDelta[] resourceDeltas = null;
47
48     /**
49      * Counter of resource deltas
50      */

51     protected int resourceDeltasCounter;
52     /**
53      * @see #getMovedFromElement()
54      */

55     protected IJavaElement movedFromHandle = null;
56     /**
57      * @see #getMovedToElement()
58      */

59     protected IJavaElement movedToHandle = null;
60     /**
61      * Empty array of IJavaElementDelta
62      */

63     protected static IJavaElementDelta[] EMPTY_DELTA= new IJavaElementDelta[] {};
64 /**
65  * Creates the root delta. To create the nested delta
66  * hierarchies use the following convenience methods. The root
67  * delta can be created at any level (for example: project, package root,
68  * package fragment...).
69  * <ul>
70  * <li><code>added(IJavaElement)</code>
71  * <li><code>changed(IJavaElement)</code>
72  * <li><code>moved(IJavaElement, IJavaElement)</code>
73  * <li><code>removed(IJavaElement)</code>
74  * <li><code>renamed(IJavaElement, IJavaElement)</code>
75  * </ul>
76  */

77 public JavaElementDelta(IJavaElement element) {
78     this.changedElement = element;
79 }
80 /**
81  * Adds the child delta to the collection of affected children. If the
82  * child is already in the collection, walk down the hierarchy.
83  */

84 protected void addAffectedChild(JavaElementDelta child) {
85     switch (this.kind) {
86         case ADDED:
87         case REMOVED:
88             // no need to add a child if this parent is added or removed
89
return;
90         case CHANGED:
91             this.changeFlags |= F_CHILDREN;
92             break;
93         default:
94             this.kind = CHANGED;
95             this.changeFlags |= F_CHILDREN;
96     }
97
98     // if a child delta is added to a compilation unit delta or below,
99
// it's a fine grained delta
100
if (this.changedElement.getElementType() >= IJavaElement.COMPILATION_UNIT) {
101         this.fineGrained();
102     }
103     
104     if (this.affectedChildren.length == 0) {
105         this.affectedChildren = new IJavaElementDelta[] {child};
106         return;
107     }
108     JavaElementDelta existingChild = null;
109     int existingChildIndex = -1;
110     if (this.affectedChildren != null) {
111         for (int i = 0; i < this.affectedChildren.length; i++) {
112             if (this.equalsAndSameParent(this.affectedChildren[i].getElement(), child.getElement())) { // handle case of two jars that can be equals but not in the same project
113
existingChild = (JavaElementDelta)this.affectedChildren[i];
114                 existingChildIndex = i;
115                 break;
116             }
117         }
118     }
119     if (existingChild == null) { //new affected child
120
this.affectedChildren= growAndAddToArray(this.affectedChildren, child);
121     } else {
122         switch (existingChild.getKind()) {
123             case ADDED:
124                 switch (child.getKind()) {
125                     case ADDED: // child was added then added -> it is added
126
case CHANGED: // child was added then changed -> it is added
127
return;
128                     case REMOVED: // child was added then removed -> noop
129
this.affectedChildren = this.removeAndShrinkArray(this.affectedChildren, existingChildIndex);
130                         return;
131                 }
132                 break;
133             case REMOVED:
134                 switch (child.getKind()) {
135                     case ADDED: // child was removed then added -> it is changed
136
child.kind = CHANGED;
137                         this.affectedChildren[existingChildIndex] = child;
138                         return;
139                     case CHANGED: // child was removed then changed -> it is removed
140
case REMOVED: // child was removed then removed -> it is removed
141
return;
142                 }
143                 break;
144             case CHANGED:
145                 switch (child.getKind()) {
146                     case ADDED: // child was changed then added -> it is added
147
case REMOVED: // child was changed then removed -> it is removed
148
this.affectedChildren[existingChildIndex] = child;
149                         return;
150                     case CHANGED: // child was changed then changed -> it is changed
151
IJavaElementDelta[] children = child.getAffectedChildren();
152                         for (int i = 0; i < children.length; i++) {
153                             JavaElementDelta childsChild = (JavaElementDelta) children[i];
154                             existingChild.addAffectedChild(childsChild);
155                         }
156                         
157                         // update flags
158
boolean childHadContentFlag = (child.changeFlags & F_CONTENT) != 0;
159                         boolean existingChildHadChildrenFlag = (existingChild.changeFlags & F_CHILDREN) != 0;
160                         existingChild.changeFlags |= child.changeFlags;
161                         
162                         // remove F_CONTENT flag if existing child had F_CHILDREN flag set
163
// (case of fine grained delta (existing child) and delta coming from
164
// DeltaProcessor (child))
165
if (childHadContentFlag && existingChildHadChildrenFlag) {
166                             existingChild.changeFlags &= ~F_CONTENT;
167                         }
168                         
169                         // add the non-java resource deltas if needed
170
// note that the child delta always takes precedence over this existing child delta
171
// as non-java resource deltas are always created last (by the DeltaProcessor)
172
IResourceDelta[] resDeltas = child.getResourceDeltas();
173                         if (resDeltas != null) {
174                             existingChild.resourceDeltas = resDeltas;
175                             existingChild.resourceDeltasCounter = child.resourceDeltasCounter;
176                         }
177                         
178                         return;
179                 }
180                 break;
181             default:
182                 // unknown -> existing child becomes the child with the existing child's flags
183
int flags = existingChild.getFlags();
184                 this.affectedChildren[existingChildIndex] = child;
185                 child.changeFlags |= flags;
186         }
187     }
188 }
189 /**
190  * Creates the nested deltas resulting from an add operation.
191  * Convenience method for creating add deltas.
192  * The constructor should be used to create the root delta
193  * and then an add operation should call this method.
194  */

195 public void added(IJavaElement element) {
196     added(element, 0);
197 }
198 public void added(IJavaElement element, int flags) {
199     JavaElementDelta addedDelta = new JavaElementDelta(element);
200     addedDelta.added();
201     addedDelta.changeFlags |= flags;
202     insertDeltaTree(element, addedDelta);
203 }
204 /**
205  * Adds the child delta to the collection of affected children. If the
206  * child is already in the collection, walk down the hierarchy.
207  */

208 protected void addResourceDelta(IResourceDelta child) {
209     switch (this.kind) {
210         case ADDED:
211         case REMOVED:
212             // no need to add a child if this parent is added or removed
213
return;
214         case CHANGED:
215             this.changeFlags |= F_CONTENT;
216             break;
217         default:
218             this.kind = CHANGED;
219             this.changeFlags |= F_CONTENT;
220     }
221     if (resourceDeltas == null) {
222         resourceDeltas = new IResourceDelta[5];
223         resourceDeltas[resourceDeltasCounter++] = child;
224         return;
225     }
226     if (resourceDeltas.length == resourceDeltasCounter) {
227         // need a resize
228
System.arraycopy(resourceDeltas, 0, (resourceDeltas = new IResourceDelta[resourceDeltasCounter * 2]), 0, resourceDeltasCounter);
229     }
230     resourceDeltas[resourceDeltasCounter++] = child;
231 }
232 /**
233  * Creates the nested deltas resulting from a change operation.
234  * Convenience method for creating change deltas.
235  * The constructor should be used to create the root delta
236  * and then a change operation should call this method.
237  */

238 public JavaElementDelta changed(IJavaElement element, int changeFlag) {
239     JavaElementDelta changedDelta = new JavaElementDelta(element);
240     changedDelta.changed(changeFlag);
241     insertDeltaTree(element, changedDelta);
242     return changedDelta;
243 }
244 /*
245  * Records the last changed AST .
246  */

247 public void changedAST(CompilationUnit changedAST) {
248     this.ast = changedAST;
249     changed(F_AST_AFFECTED);
250 }
251 /**
252  * Mark this delta as a content changed delta.
253  */

254 public void contentChanged() {
255     this.changeFlags |= F_CONTENT;
256 }
257 /**
258  * Creates the nested deltas for a closed element.
259  */

260 public void closed(IJavaElement element) {
261     JavaElementDelta delta = new JavaElementDelta(element);
262     delta.changed(F_CLOSED);
263     insertDeltaTree(element, delta);
264 }
265 /**
266  * Creates the nested delta deltas based on the affected element
267  * its delta, and the root of this delta tree. Returns the root
268  * of the created delta tree.
269  */

270 protected JavaElementDelta createDeltaTree(IJavaElement element, JavaElementDelta delta) {
271     JavaElementDelta childDelta = delta;
272     ArrayList JavaDoc ancestors= getAncestors(element);
273     if (ancestors == null) {
274         if (this.equalsAndSameParent(delta.getElement(), getElement())) { // handle case of two jars that can be equals but not in the same project
275
// the element being changed is the root element
276
this.kind= delta.kind;
277             this.changeFlags = delta.changeFlags;
278             this.movedToHandle = delta.movedToHandle;
279             this.movedFromHandle = delta.movedFromHandle;
280         }
281     } else {
282         for (int i = 0, size = ancestors.size(); i < size; i++) {
283             IJavaElement ancestor = (IJavaElement) ancestors.get(i);
284             JavaElementDelta ancestorDelta = new JavaElementDelta(ancestor);
285             ancestorDelta.addAffectedChild(childDelta);
286             childDelta = ancestorDelta;
287         }
288     }
289     return childDelta;
290 }
291 /**
292  * Returns whether the two java elements are equals and have the same parent.
293  */

294 protected boolean equalsAndSameParent(IJavaElement e1, IJavaElement e2) {
295     IJavaElement parent1;
296     return e1.equals(e2) && ((parent1 = e1.getParent()) != null) && parent1.equals(e2.getParent());
297 }
298 /**
299  * Returns the <code>JavaElementDelta</code> for the given element
300  * in the delta tree, or null, if no delta for the given element is found.
301  */

302 protected JavaElementDelta find(IJavaElement e) {
303     if (this.equalsAndSameParent(this.changedElement, e)) { // handle case of two jars that can be equals but not in the same project
304
return this;
305     } else {
306         for (int i = 0; i < this.affectedChildren.length; i++) {
307             JavaElementDelta delta = ((JavaElementDelta)this.affectedChildren[i]).find(e);
308             if (delta != null) {
309                 return delta;
310             }
311         }
312     }
313     return null;
314 }
315 /**
316  * Mark this delta as a fine-grained delta.
317  */

318 public void fineGrained() {
319     changed(F_FINE_GRAINED);
320 }
321 /**
322  * @see IJavaElementDelta
323  */

324 public IJavaElementDelta[] getAddedChildren() {
325     return getChildrenOfType(ADDED);
326 }
327 /**
328  * @see IJavaElementDelta
329  */

330 public IJavaElementDelta[] getAffectedChildren() {
331     return this.affectedChildren;
332 }
333 /**
334  * Returns a collection of all the parents of this element up to (but
335  * not including) the root of this tree in bottom-up order. If the given
336  * element is not a descendant of the root of this tree, <code>null</code>
337  * is returned.
338  */

339 private ArrayList JavaDoc getAncestors(IJavaElement element) {
340     IJavaElement parent = element.getParent();
341     if (parent == null) {
342         return null;
343     }
344     ArrayList JavaDoc parents = new ArrayList JavaDoc();
345     while (!parent.equals(this.changedElement)) {
346         parents.add(parent);
347         parent = parent.getParent();
348         if (parent == null) {
349             return null;
350         }
351     }
352     parents.trimToSize();
353     return parents;
354 }
355 public CompilationUnit getCompilationUnitAST() {
356     return this.ast;
357 }
358 /**
359  * @see IJavaElementDelta
360  */

361 public IJavaElementDelta[] getChangedChildren() {
362     return getChildrenOfType(CHANGED);
363 }
364 /**
365  * @see IJavaElementDelta
366  */

367 protected IJavaElementDelta[] getChildrenOfType(int type) {
368     int length = this.affectedChildren.length;
369     if (length == 0) {
370         return new IJavaElementDelta[] {};
371     }
372     ArrayList JavaDoc children= new ArrayList JavaDoc(length);
373     for (int i = 0; i < length; i++) {
374         if (this.affectedChildren[i].getKind() == type) {
375             children.add(this.affectedChildren[i]);
376         }
377     }
378
379     IJavaElementDelta[] childrenOfType = new IJavaElementDelta[children.size()];
380     children.toArray(childrenOfType);
381     
382     return childrenOfType;
383 }
384 /**
385  * Returns the delta for a given element. Only looks below this
386  * delta.
387  */

388 protected JavaElementDelta getDeltaFor(IJavaElement element) {
389     if (this.equalsAndSameParent(getElement(), element)) // handle case of two jars that can be equals but not in the same project
390
return this;
391     if (this.affectedChildren.length == 0)
392         return null;
393     int childrenCount = this.affectedChildren.length;
394     for (int i = 0; i < childrenCount; i++) {
395         JavaElementDelta delta = (JavaElementDelta)this.affectedChildren[i];
396         if (this.equalsAndSameParent(delta.getElement(), element)) { // handle case of two jars that can be equals but not in the same project
397
return delta;
398         } else {
399             delta = delta.getDeltaFor(element);
400             if (delta != null)
401                 return delta;
402         }
403     }
404     return null;
405 }
406 /**
407  * @see IJavaElementDelta
408  */

409 public IJavaElement getElement() {
410     return this.changedElement;
411 }
412 /**
413  * @see IJavaElementDelta
414  */

415 public IJavaElement getMovedFromElement() {
416     return this.movedFromHandle;
417 }
418 /**
419  * @see IJavaElementDelta
420  */

421 public IJavaElement getMovedToElement() {
422     return movedToHandle;
423 }
424 /**
425  * @see IJavaElementDelta
426  */

427 public IJavaElementDelta[] getRemovedChildren() {
428     return getChildrenOfType(REMOVED);
429 }
430 /**
431  * Return the collection of resource deltas. Return null if none.
432  */

433 public IResourceDelta[] getResourceDeltas() {
434     if (resourceDeltas == null) return null;
435     if (resourceDeltas.length != resourceDeltasCounter) {
436         System.arraycopy(resourceDeltas, 0, resourceDeltas = new IResourceDelta[resourceDeltasCounter], 0, resourceDeltasCounter);
437     }
438     return resourceDeltas;
439 }
440 /**
441  * Adds the new element to a new array that contains all of the elements of the old array.
442  * Returns the new array.
443  */

444 protected IJavaElementDelta[] growAndAddToArray(IJavaElementDelta[] array, IJavaElementDelta addition) {
445     IJavaElementDelta[] old = array;
446     array = new IJavaElementDelta[old.length + 1];
447     System.arraycopy(old, 0, array, 0, old.length);
448     array[old.length] = addition;
449     return array;
450 }
451 /**
452  * Creates the delta tree for the given element and delta, and then
453  * inserts the tree as an affected child of this node.
454  */

455 protected void insertDeltaTree(IJavaElement element, JavaElementDelta delta) {
456     JavaElementDelta childDelta= createDeltaTree(element, delta);
457     if (!this.equalsAndSameParent(element, getElement())) { // handle case of two jars that can be equals but not in the same project
458
addAffectedChild(childDelta);
459     }
460 }
461 /**
462  * Creates the nested deltas resulting from an move operation.
463  * Convenience method for creating the "move from" delta.
464  * The constructor should be used to create the root delta
465  * and then the move operation should call this method.
466  */

467 public void movedFrom(IJavaElement movedFromElement, IJavaElement movedToElement) {
468     JavaElementDelta removedDelta = new JavaElementDelta(movedFromElement);
469     removedDelta.kind = REMOVED;
470     removedDelta.changeFlags |= F_MOVED_TO;
471     removedDelta.movedToHandle = movedToElement;
472     insertDeltaTree(movedFromElement, removedDelta);
473 }
474 /**
475  * Creates the nested deltas resulting from an move operation.
476  * Convenience method for creating the "move to" delta.
477  * The constructor should be used to create the root delta
478  * and then the move operation should call this method.
479  */

480 public void movedTo(IJavaElement movedToElement, IJavaElement movedFromElement) {
481     JavaElementDelta addedDelta = new JavaElementDelta(movedToElement);
482     addedDelta.kind = ADDED;
483     addedDelta.changeFlags |= F_MOVED_FROM;
484     addedDelta.movedFromHandle = movedFromElement;
485     insertDeltaTree(movedToElement, addedDelta);
486 }
487 /**
488  * Creates the nested deltas for an opened element.
489  */

490 public void opened(IJavaElement element) {
491     JavaElementDelta delta = new JavaElementDelta(element);
492     delta.changed(F_OPENED);
493     insertDeltaTree(element, delta);
494 }
495 /**
496  * Removes the child delta from the collection of affected children.
497  */

498 protected void removeAffectedChild(JavaElementDelta child) {
499     int index = -1;
500     if (this.affectedChildren != null) {
501         for (int i = 0; i < this.affectedChildren.length; i++) {
502             if (this.equalsAndSameParent(this.affectedChildren[i].getElement(), child.getElement())) { // handle case of two jars that can be equals but not in the same project
503
index = i;
504                 break;
505             }
506         }
507     }
508     if (index >= 0) {
509         this.affectedChildren= removeAndShrinkArray(this.affectedChildren, index);
510     }
511 }
512 /**
513  * Removes the element from the array.
514  * Returns the a new array which has shrunk.
515  */

516 protected IJavaElementDelta[] removeAndShrinkArray(IJavaElementDelta[] old, int index) {
517     IJavaElementDelta[] array = new IJavaElementDelta[old.length - 1];
518     if (index > 0)
519         System.arraycopy(old, 0, array, 0, index);
520     int rest = old.length - index - 1;
521     if (rest > 0)
522         System.arraycopy(old, index + 1, array, index, rest);
523     return array;
524 }
525 /**
526  * Creates the nested deltas resulting from an delete operation.
527  * Convenience method for creating removed deltas.
528  * The constructor should be used to create the root delta
529  * and then the delete operation should call this method.
530  */

531 public void removed(IJavaElement element) {
532     removed(element, 0);
533 }
534 public void removed(IJavaElement element, int flags) {
535     JavaElementDelta removedDelta= new JavaElementDelta(element);
536     insertDeltaTree(element, removedDelta);
537     JavaElementDelta actualDelta = getDeltaFor(element);
538     if (actualDelta != null) {
539         actualDelta.removed();
540         actualDelta.changeFlags |= flags;
541         actualDelta.affectedChildren = EMPTY_DELTA;
542     }
543 }
544 /**
545  * Creates the nested deltas resulting from a change operation.
546  * Convenience method for creating change deltas.
547  * The constructor should be used to create the root delta
548  * and then a change operation should call this method.
549  */

550 public void sourceAttached(IJavaElement element) {
551     JavaElementDelta attachedDelta = new JavaElementDelta(element);
552     attachedDelta.changed(F_SOURCEATTACHED);
553     insertDeltaTree(element, attachedDelta);
554 }
555 /**
556  * Creates the nested deltas resulting from a change operation.
557  * Convenience method for creating change deltas.
558  * The constructor should be used to create the root delta
559  * and then a change operation should call this method.
560  */

561 public void sourceDetached(IJavaElement element) {
562     JavaElementDelta detachedDelta = new JavaElementDelta(element);
563     detachedDelta.changed(F_SOURCEDETACHED);
564     insertDeltaTree(element, detachedDelta);
565 }
566 /**
567  * Returns a string representation of this delta's
568  * structure suitable for debug purposes.
569  *
570  * @see #toString()
571  */

572 public String JavaDoc toDebugString(int depth) {
573     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
574     for (int i= 0; i < depth; i++) {
575         buffer.append('\t');
576     }
577     buffer.append(((JavaElement)getElement()).toDebugString());
578     toDebugString(buffer);
579     IJavaElementDelta[] children = getAffectedChildren();
580     if (children != null) {
581         for (int i = 0; i < children.length; ++i) {
582             buffer.append("\n"); //$NON-NLS-1$
583
buffer.append(((JavaElementDelta) children[i]).toDebugString(depth + 1));
584         }
585     }
586     for (int i = 0; i < resourceDeltasCounter; i++) {
587         buffer.append("\n");//$NON-NLS-1$
588
for (int j = 0; j < depth+1; j++) {
589             buffer.append('\t');
590         }
591         IResourceDelta resourceDelta = resourceDeltas[i];
592         buffer.append(resourceDelta.toString());
593         buffer.append("["); //$NON-NLS-1$
594
switch (resourceDelta.getKind()) {
595             case IResourceDelta.ADDED :
596                 buffer.append('+');
597                 break;
598             case IResourceDelta.REMOVED :
599                 buffer.append('-');
600                 break;
601             case IResourceDelta.CHANGED :
602                 buffer.append('*');
603                 break;
604             default :
605                 buffer.append('?');
606                 break;
607         }
608         buffer.append("]"); //$NON-NLS-1$
609
}
610     return buffer.toString();
611 }
612 protected boolean toDebugString(StringBuffer JavaDoc buffer, int flags) {
613     boolean prev = super.toDebugString(buffer, flags);
614
615     if ((flags & IJavaElementDelta.F_CHILDREN) != 0) {
616         if (prev)
617             buffer.append(" | "); //$NON-NLS-1$
618
buffer.append("CHILDREN"); //$NON-NLS-1$
619
prev = true;
620     }
621     if ((flags & IJavaElementDelta.F_CONTENT) != 0) {
622         if (prev)
623             buffer.append(" | "); //$NON-NLS-1$
624
buffer.append("CONTENT"); //$NON-NLS-1$
625
prev = true;
626     }
627     if ((flags & IJavaElementDelta.F_MOVED_FROM) != 0) {
628         if (prev)
629             buffer.append(" | "); //$NON-NLS-1$
630
buffer.append("MOVED_FROM(" + ((JavaElement)getMovedFromElement()).toStringWithAncestors() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
631
prev = true;
632     }
633     if ((flags & IJavaElementDelta.F_MOVED_TO) != 0) {
634         if (prev)
635             buffer.append(" | "); //$NON-NLS-1$
636
buffer.append("MOVED_TO(" + ((JavaElement)getMovedToElement()).toStringWithAncestors() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
637
prev = true;
638     }
639     if ((flags & IJavaElementDelta.F_ADDED_TO_CLASSPATH) != 0) {
640         if (prev)
641             buffer.append(" | "); //$NON-NLS-1$
642
buffer.append("ADDED TO CLASSPATH"); //$NON-NLS-1$
643
prev = true;
644     }
645     if ((flags & IJavaElementDelta.F_REMOVED_FROM_CLASSPATH) != 0) {
646         if (prev)
647             buffer.append(" | "); //$NON-NLS-1$
648
buffer.append("REMOVED FROM CLASSPATH"); //$NON-NLS-1$
649
prev = true;
650     }
651     if ((flags & IJavaElementDelta.F_REORDER) != 0) {
652         if (prev)
653             buffer.append(" | "); //$NON-NLS-1$
654
buffer.append("REORDERED"); //$NON-NLS-1$
655
prev = true;
656     }
657     if ((flags & IJavaElementDelta.F_ARCHIVE_CONTENT_CHANGED) != 0) {
658         if (prev)
659             buffer.append(" | "); //$NON-NLS-1$
660
buffer.append("ARCHIVE CONTENT CHANGED"); //$NON-NLS-1$
661
prev = true;
662     }
663     if ((flags & IJavaElementDelta.F_SOURCEATTACHED) != 0) {
664         if (prev)
665             buffer.append(" | "); //$NON-NLS-1$
666
buffer.append("SOURCE ATTACHED"); //$NON-NLS-1$
667
prev = true;
668     }
669     if ((flags & IJavaElementDelta.F_SOURCEDETACHED) != 0) {
670         if (prev)
671             buffer.append(" | "); //$NON-NLS-1$
672
buffer.append("SOURCE DETACHED"); //$NON-NLS-1$
673
prev = true;
674     }
675     if ((flags & IJavaElementDelta.F_FINE_GRAINED) != 0) {
676         if (prev)
677             buffer.append(" | "); //$NON-NLS-1$
678
buffer.append("FINE GRAINED"); //$NON-NLS-1$
679
prev = true;
680     }
681     if ((flags & IJavaElementDelta.F_PRIMARY_WORKING_COPY) != 0) {
682         if (prev)
683             buffer.append(" | "); //$NON-NLS-1$
684
buffer.append("PRIMARY WORKING COPY"); //$NON-NLS-1$
685
prev = true;
686     }
687     if ((flags & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0) {
688         if (prev)
689             buffer.append(" | "); //$NON-NLS-1$
690
buffer.append("CLASSPATH CHANGED"); //$NON-NLS-1$
691
prev = true;
692     }
693     if ((flags & IJavaElementDelta.F_PRIMARY_RESOURCE) != 0) {
694         if (prev)
695             buffer.append(" | "); //$NON-NLS-1$
696
buffer.append("PRIMARY RESOURCE"); //$NON-NLS-1$
697
prev = true;
698     }
699     if ((flags & IJavaElementDelta.F_OPENED) != 0) {
700         if (prev)
701             buffer.append(" | "); //$NON-NLS-1$
702
buffer.append("OPENED"); //$NON-NLS-1$
703
prev = true;
704     }
705     if ((flags & IJavaElementDelta.F_CLOSED) != 0) {
706         if (prev)
707             buffer.append(" | "); //$NON-NLS-1$
708
buffer.append("CLOSED"); //$NON-NLS-1$
709
prev = true;
710     }
711     if ((flags & IJavaElementDelta.F_AST_AFFECTED) != 0) {
712         if (prev)
713             buffer.append(" | "); //$NON-NLS-1$
714
buffer.append("AST AFFECTED"); //$NON-NLS-1$
715
prev = true;
716     }
717     if ((flags & IJavaElementDelta.F_CATEGORIES) != 0) {
718         if (prev)
719             buffer.append(" | "); //$NON-NLS-1$
720
buffer.append("CATEGORIES"); //$NON-NLS-1$
721
prev = true;
722     }
723     return prev;
724 }
725 /**
726  * Returns a string representation of this delta's
727  * structure suitable for debug purposes.
728  */

729 public String JavaDoc toString() {
730     return toDebugString(0);
731 }
732 }
733
Popular Tags