Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipe Mulet2001-06-27 11:27:24 +0000
committerPhilipe Mulet2001-06-27 11:27:24 +0000
commit6a230a9d6ae1a4a6adbf38879cb9ee685eccffe9 (patch)
treee05b8ab1235babd084ed8b274999d167d939ae44 /org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
parentb04602938404af4f8569a399fb36a5018768a262 (diff)
downloadeclipse.jdt.core-6a230a9d6ae1a4a6adbf38879cb9ee685eccffe9.tar.gz
eclipse.jdt.core-6a230a9d6ae1a4a6adbf38879cb9ee685eccffe9.tar.xz
eclipse.jdt.core-6a230a9d6ae1a4a6adbf38879cb9ee685eccffe9.zip
externalization in progress
Diffstat (limited to 'org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java')
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java483
1 files changed, 195 insertions, 288 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
index 7fb0da2cb5..dbf9941335 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/impl/DeltaImpl.java
@@ -14,10 +14,10 @@ import java.util.*;
class DeltaImpl implements IDelta {
protected IDelta fParent;
protected IDelta[] fChildren;
-
+
/* Non state specific object */
protected Object fObject;
-
+
protected String fName;
protected DeltaKey fKey;
@@ -29,7 +29,7 @@ class DeltaImpl implements IDelta {
/* names for checklist items */
public static final String fgImage = "Image";
-
+
public static final String fgPackageCategory = "Packages";
public static final String fgTypeCategory = "Types";
public static final String fgBinaryCategory = "Binaries";
@@ -57,60 +57,47 @@ class DeltaImpl implements IDelta {
/* shared empty array */
protected static final IDelta[] fgEmptyArray = new IDelta[0];
-
+
protected IncrementalImageBuilder fIncrementalBuilder;
static final int PS_CHANGED = 1; // has the principal structure changed?
- static final int BIN_CHANGED = 2; // has the binary changed?
-
+ static final int BIN_CHANGED = 2; // has the binary changed?
+
/**
* Creates a new root image delta
*/
DeltaImpl(IncrementalImageBuilder builder, IImageContext context) {
this(builder.getOldState(), builder.getNewState(), context, builder);
}
-
/**
* Creates a new root image delta
*/
- protected DeltaImpl(
- StateImpl oldState,
- StateImpl newState,
- String name,
- Object o,
- DeltaKey key,
- IDelta parent,
- int status) {
-
- fNewState = (StateImpl) newState;
- fOldState = (StateImpl) oldState;
+ protected DeltaImpl(StateImpl oldState, StateImpl newState, String name,
+ Object o, DeltaKey key, IDelta parent, int status) {
+
+ fNewState = (StateImpl)newState;
+ fOldState = (StateImpl)oldState;
fName = name;
fObject = o;
fParent = parent;
fKey = key;
fStatus = status;
- fChildren = fgEmptyArray;
+ fChildren = fgEmptyArray;
fContext = parent.getImageContext();
}
-
/**
* Creates a new root image delta
*/
DeltaImpl(IState oldState, IState newState, IImageContext context) {
this(oldState, newState, context, null);
}
-
/**
* Creates a new root image delta
*/
- DeltaImpl(
- IState oldState,
- IState newState,
- IImageContext context,
- IncrementalImageBuilder builder) {
+ DeltaImpl(IState oldState, IState newState, IImageContext context, IncrementalImageBuilder builder) {
try {
- fNewState = (StateImpl) newState;
- fOldState = (StateImpl) oldState;
+ fNewState = (StateImpl)newState;
+ fOldState = (StateImpl)oldState;
} catch (ClassCastException cce) {
Assert.isTrue(false, "Invalid states");
}
@@ -124,24 +111,22 @@ class DeltaImpl implements IDelta {
fIncrementalBuilder = builder;
computeImageDelta();
}
-
/**
* Creates and returns a child with the given name and object
*/
protected DeltaImpl add(String name, Object object, int status) {
return add(name, object, getKey().add(object), status);
}
-
/**
* Creates and returns a child with the given name and object
*/
protected DeltaImpl add(String name, Object object, DeltaKey key, int status) {
- return new DeltaImpl(fOldState, fNewState, //same states as me
- name, object, key, //given name, object and key
- this, //parent
- status); //added, removed, or changed
+ return new DeltaImpl(
+ fOldState, fNewState, //same states as me
+ name, object, key, //given name, object and key
+ this, //parent
+ status); //added, removed, or changed
}
-
/**
* Returns the child of this delta with the given object
*/
@@ -152,7 +137,8 @@ class DeltaImpl implements IDelta {
if (o.equals(fChildren[i].getName())) {
return fChildren[i];
}
- } else {
+ }
+ else {
if (o.equals(fChildren[i].getObject())) {
return fChildren[i];
}
@@ -161,54 +147,52 @@ class DeltaImpl implements IDelta {
/* not found */
return null;
}
+/**
+ * Compares the type in the old and new states.
+ * Returns a bit mask indicating whether the principal structure or binary have changed.
+ */
+protected int compareBuilderType(BuilderType type) {
- /**
- * Compares the type in the old and new states.
- * Returns a bit mask indicating whether the principal structure or binary have changed.
- */
- protected int compareBuilderType(BuilderType type) {
-
- if (!type.isAffected()) {
- return 0;
- }
-
- TypeStructureEntry oldEntry = type.getOldTypeStructureEntry();
- TypeStructureEntry newEntry = type.getNewTypeStructureEntry();
- if (oldEntry == null || newEntry == null) {
- return PS_CHANGED | BIN_CHANGED;
- }
- if (oldEntry == newEntry) {
- return 0;
- }
-
- int result = 0;
+ if (!type.isAffected()) {
+ return 0;
+ }
+
+ TypeStructureEntry oldEntry = type.getOldTypeStructureEntry();
+ TypeStructureEntry newEntry = type.getNewTypeStructureEntry();
+ if (oldEntry == null || newEntry == null) {
+ return PS_CHANGED | BIN_CHANGED;
+ }
+ if (oldEntry == newEntry) {
+ return 0;
+ }
- IBinaryType oldType = type.getOldBinaryType();
- IBinaryType newType = type.getNewBinaryType();
+ int result = 0;
- if (!BinaryStructure.compare(oldType, newType)) {
- result |= PS_CHANGED;
- }
- /*
- * If the source entry has changed, consider the binary to have changed
- * even if the binary is actually the same. Some clients, such as the
- * target manager, need to know when the source changes.
- */
- if (!oldEntry.getSourceEntry().equals(newEntry.getSourceEntry())) {
+ IBinaryType oldType = type.getOldBinaryType();
+ IBinaryType newType = type.getNewBinaryType();
+
+ if (!BinaryStructure.compare(oldType, newType)) {
+ result |= PS_CHANGED;
+ }
+ /*
+ * If the source entry has changed, consider the binary to have changed
+ * even if the binary is actually the same. Some clients, such as the
+ * target manager, need to know when the source changes.
+ */
+ if (!oldEntry.getSourceEntry().equals(newEntry.getSourceEntry())) {
+ result |= BIN_CHANGED;
+ } else
+ if (oldEntry.getCRC32() != newEntry.getCRC32()) {
result |= BIN_CHANGED;
- } else
- if (oldEntry.getCRC32() != newEntry.getCRC32()) {
+ } else {
+ boolean oldIsBinary = oldEntry.isBinary();
+ boolean newIsBinary = newEntry.isBinary();
+ if (oldIsBinary != newIsBinary) {
result |= BIN_CHANGED;
- } else {
- boolean oldIsBinary = oldEntry.isBinary();
- boolean newIsBinary = newEntry.isBinary();
- if (oldIsBinary != newIsBinary) {
- result |= BIN_CHANGED;
- }
}
- return result;
- }
-
+ }
+ return result;
+}
/**
* Returns an integer indicating whether anotherDelta is less than, equal to,
* or greater than this delta.
@@ -218,52 +202,50 @@ class DeltaImpl implements IDelta {
Assert.isTrue(false, "TBD");
return 0;
}
+/**
+ * Compares the type in the old and new states.
+ * Returns a bit mask indicating whether the principal structure or binary have changed.
+ */
+protected int compareTypes(IType handle) {
+ if (fIncrementalBuilder != null) {
+ return compareBuilderType(fIncrementalBuilder.getBuilderType(handle));
+ }
- /**
- * Compares the type in the old and new states.
- * Returns a bit mask indicating whether the principal structure or binary have changed.
- */
- protected int compareTypes(IType handle) {
- if (fIncrementalBuilder != null) {
- return compareBuilderType(fIncrementalBuilder.getBuilderType(handle));
- }
-
- TypeStructureEntry oldEntry = fOldState.getTypeStructureEntry(handle, true);
- TypeStructureEntry newEntry = fNewState.getTypeStructureEntry(handle, true);
- if (oldEntry == null || newEntry == null) {
- return PS_CHANGED | BIN_CHANGED;
- }
- if (oldEntry == newEntry) {
- return 0;
- }
- int result = 0;
-
- IBinaryType oldType = fOldState.getBinaryType(oldEntry);
- IBinaryType newType = fNewState.getBinaryType(newEntry);
+ TypeStructureEntry oldEntry = fOldState.getTypeStructureEntry(handle, true);
+ TypeStructureEntry newEntry = fNewState.getTypeStructureEntry(handle, true);
+ if (oldEntry == null || newEntry == null) {
+ return PS_CHANGED | BIN_CHANGED;
+ }
+ if (oldEntry == newEntry) {
+ return 0;
+ }
+ int result = 0;
- if (!BinaryStructure.compare(oldType, newType)) {
- result |= PS_CHANGED;
- }
- /*
- * If the source entry has changed, consider the binary to have changed
- * even if the binary is actually the same. Some clients, such as the
- * target manager, need to know when the source changes.
- */
- if (!oldEntry.getSourceEntry().equals(newEntry.getSourceEntry())) {
+ IBinaryType oldType = fOldState.getBinaryType(oldEntry);
+ IBinaryType newType = fNewState.getBinaryType(newEntry);
+
+ if (!BinaryStructure.compare(oldType, newType)) {
+ result |= PS_CHANGED;
+ }
+ /*
+ * If the source entry has changed, consider the binary to have changed
+ * even if the binary is actually the same. Some clients, such as the
+ * target manager, need to know when the source changes.
+ */
+ if (!oldEntry.getSourceEntry().equals(newEntry.getSourceEntry())) {
+ result |= BIN_CHANGED;
+ } else
+ if (oldEntry.getCRC32() != newEntry.getCRC32()) {
result |= BIN_CHANGED;
- } else
- if (oldEntry.getCRC32() != newEntry.getCRC32()) {
+ } else {
+ boolean oldIsBinary = oldEntry.isBinary();
+ boolean newIsBinary = newEntry.isBinary();
+ if (oldIsBinary != newIsBinary) {
result |= BIN_CHANGED;
- } else {
- boolean oldIsBinary = oldEntry.isBinary();
- boolean newIsBinary = newEntry.isBinary();
- if (oldIsBinary != newIsBinary) {
- result |= BIN_CHANGED;
- }
}
- return result;
- }
-
+ }
+ return result;
+}
/**
* Computes the added classes for each added package.
* Returns a DeltaInfo object for each package describing the affected
@@ -283,35 +265,30 @@ class DeltaImpl implements IDelta {
types[j] = (IType) types[j].nonStateSpecific();
}
infos[i].addedTypes = types;
- } //next package
+ }//next package
return infos;
- } //end function
-
+ }//end function
/**
* Computes added, removed, and changed classes for a set of packages.
* Stores vectors of IType handles.
*/
- protected void computeAllClasses(
- IPackage pkg,
- Vector added,
- Vector removed,
- Vector changedTypes,
- Vector changedBinaries) {
-
+ protected void computeAllClasses(IPackage pkg,
+ Vector added, Vector removed, Vector changedTypes, Vector changedBinaries) {
+
/* collect a set of all classes in old package */
/* we have to make a copy here to avoid destroying the state */
Hashtable oldTypeTable = new Hashtable();
IType[] oldTypes = ((IPackage) pkg.inState(fOldState)).getAllClasses();
for (int i = 0; i < oldTypes.length; i++) {
- IType handle = (IType) oldTypes[i].nonStateSpecific();
+ IType handle = (IType)oldTypes[i].nonStateSpecific();
oldTypeTable.put(handle, handle);
}
/* iterate through new classes */
- IType[] newTypes = ((IPackage) pkg.inState(fNewState)).getAllClasses();
+ IType[] newTypes = ((IPackage)pkg.inState(fNewState)).getAllClasses();
for (int i = 0; i < newTypes.length; i++) {
- IType handle = (IType) newTypes[i].nonStateSpecific();
+ IType handle = (IType)newTypes[i].nonStateSpecific();
if (oldTypeTable.remove(handle) != null) {
/* class is in both packages */
int code = compareTypes(handle);
@@ -332,7 +309,6 @@ class DeltaImpl implements IDelta {
removed.addElement(e.nextElement());
}
}
-
/**
* Computes added, removed, and changed packages. At this
* stage, if a package hasn't been added or removed, it is
@@ -342,34 +318,34 @@ class DeltaImpl implements IDelta {
* specific package handles.
*/
protected void computeAllPackages(
- Vector added,
- Vector removed,
- Vector changed) {
+ Vector added, Vector removed, Vector changed) {
/* do for each affected package */
- for (Enumeration e = getAffectedPackages(); e.hasMoreElements();) {
- IPackage pkg = (IPackage) e.nextElement();
+ for (Enumeration e = getAffectedPackages();e.hasMoreElements();) {
+ IPackage pkg = (IPackage)e.nextElement();
boolean inOld = pkg.inState(fOldState).isPresent();
boolean inNew = pkg.inState(fNewState).isPresent();
if (inOld) {
if (inNew) {
changed.addElement(pkg);
- } else {
+ }
+ else {
// Package was removed.
removed.addElement(pkg);
}
- } else {
+ }
+ else {
if (inNew) {
// Package was added.
added.addElement(pkg);
- } else {
+ }
+ else {
// Package was in image context but was not in either state.
// Ignore it.
}
}
}
}
-
/**
* Computes added, removed, and changed classes for a set of packages.
* Returns a DeltaInfo object for each package describing the affected
@@ -381,7 +357,7 @@ class DeltaImpl implements IDelta {
Vector toRemove = new Vector();
for (Enumeration pkgEnum = pkgs.elements(); pkgEnum.hasMoreElements();) {
- IPackage pkg = (IPackage) pkgEnum.nextElement();
+ IPackage pkg = (IPackage)pkgEnum.nextElement();
Vector vAdded = new Vector();
Vector vRemoved = new Vector();
@@ -401,10 +377,10 @@ class DeltaImpl implements IDelta {
pkgInfo.removedTypes = new IType[vRemoved.size()];
vRemoved.copyInto(pkgInfo.removedTypes);
-
+
pkgInfo.changedTypes = new IType[vChanged.size()];
vChanged.copyInto(pkgInfo.changedTypes);
-
+
pkgInfo.changedBinaries = new IType[vBinaries.size()];
vBinaries.copyInto(pkgInfo.changedBinaries);
@@ -413,7 +389,7 @@ class DeltaImpl implements IDelta {
/* remove the element -- can't delete while enumerating */
toRemove.addElement(pkg);
}
- } //next package
+ }//next package
/* remove packages with no changes */
for (Enumeration e = toRemove.elements(); e.hasMoreElements();) {
@@ -421,13 +397,12 @@ class DeltaImpl implements IDelta {
}
Assert.isTrue(vInfo.size() == pkgs.size(), "sanity check");
-
+
/* convert info vector to array */
PackageInfo[] infos = new PackageInfo[vInfo.size()];
vInfo.copyInto(infos);
return infos;
- } //end function
-
+ }//end function
/**
* Calculates the added, removed, and changed packages, types and methods
* that consitute an image delta. The results are stored in the supplied
@@ -449,7 +424,6 @@ class DeltaImpl implements IDelta {
return info;
}
-
/**
* Computes the image delta.
*/
@@ -459,29 +433,25 @@ class DeltaImpl implements IDelta {
DeltaInfo info = computeDeltaInfo();
/* create categories, any or all of them may be null */
- IDelta pkgCategory = createPackageCategory(this, info);
+ IDelta pkgCategory = createPackageCategory(this, info);
IDelta typeCategory = createCategory(this, info, fgTypeCategory);
IDelta binaryCategory = createCategory(this, info, fgBinaryCategory);
/* Create top level children */
int childCount = 0;
- if (pkgCategory != null)
- childCount++;
- if (typeCategory != null)
- childCount++;
- if (binaryCategory != null)
- childCount++;
+ if (pkgCategory != null) childCount++;
+ if (typeCategory != null) childCount++;
+ if (binaryCategory != null) childCount++;
fChildren = new IDelta[childCount];
childCount = 0;
- if (pkgCategory != null)
+ if (pkgCategory != null)
fChildren[childCount++] = pkgCategory;
- if (typeCategory != null)
+ if (typeCategory != null)
fChildren[childCount++] = typeCategory;
- if (binaryCategory != null)
+ if (binaryCategory != null)
fChildren[childCount++] = binaryCategory;
}
-
/**
* Computes the removed classes for each removed package.
* Returns a DeltaInfo object for each package describing the affected
@@ -501,19 +471,15 @@ class DeltaImpl implements IDelta {
types[j] = (IType) types[j].nonStateSpecific();
}
infos[i].removedTypes = types;
- } //next package
+ }//next package
return infos;
- } //end function
-
+ }//end function
/**
* Converts a vector of handles to an array of delta info objects of the given
* type.
*/
- protected IDelta[] convertHandlesToDeltaArray(
- Vector vHandles,
- String type,
- int status) {
+ protected IDelta[] convertHandlesToDeltaArray(Vector vHandles, String type, int status) {
int i = 0;
IDelta[] results = new IDelta[vHandles.size()];
@@ -522,20 +488,16 @@ class DeltaImpl implements IDelta {
}
return results;
}
-
/**
* Copies information from a PackageInfo to the children of a DeltaImpl.
* If types is true, copy the type information, otherwise copy the binary information
*/
- protected void copyInfoToChildren(
- DeltaImpl delta,
- PackageInfo info,
- boolean types) {
+ protected void copyInfoToChildren(DeltaImpl delta, PackageInfo info, boolean types) {
/* are we looking at binaries or types ? */
IType[] changed = types ? info.changedTypes : info.changedBinaries;
String name = types ? fgType : fgBinary;
-
+
int count = info.addedTypes.length + info.removedTypes.length + changed.length;
if (count == 0) {
delta.fStatus = SAME;
@@ -555,38 +517,27 @@ class DeltaImpl implements IDelta {
}
delta.setChildren(children);
}
-
/**
* Creates the types category of the image delta. Returns
* the Delta object for the category. If there are no added,
* removed, or changed types, returns null.
*/
- protected IDelta createCategory(
- DeltaImpl parent,
- DeltaInfo info,
- String categoryName) {
-
- int size =
- info.changedPkgs.length + info.addedPkgs.length + info.removedPkgs.length;
- if (size == 0)
- return null;
+ protected IDelta createCategory(DeltaImpl parent, DeltaInfo info, String categoryName) {
+ int size = info.changedPkgs.length + info.addedPkgs.length + info.removedPkgs.length;
+ if (size == 0) return null;
+
/* collection of packages that are children of the type category */
IDelta[] children = new IDelta[size];
/* create Type category node */
- DeltaImpl category =
- parent.add(
- categoryName,
- parent.getObject(),
- parent.getKey().add(categoryName),
- CHANGED);
-
+ DeltaImpl category = parent.add(categoryName, parent.getObject(), parent.getKey().add(categoryName), CHANGED);
+
/* create new deltas for changed packages */
int count = 0;
for (int i = 0; i < info.changedPkgs.length; i++) {
PackageInfo pkgInfo = info.changedPkgs[i];
- DeltaImpl child = (DeltaImpl) category.add(fgPackage, pkgInfo.pkg, CHANGED);
+ DeltaImpl child = (DeltaImpl)category.add(fgPackage, pkgInfo.pkg, CHANGED);
copyInfoToChildren(child, pkgInfo, categoryName == fgTypeCategory);
children[count++] = child;
}
@@ -596,14 +547,12 @@ class DeltaImpl implements IDelta {
children[count++] = category.packageForTypeCategory(ADDED, info.addedPkgs[i]);
}
for (int i = 0; i < info.removedPkgs.length; i++) {
- children[count++] =
- category.packageForTypeCategory(REMOVED, info.removedPkgs[i]);
+ children[count++] = category.packageForTypeCategory(REMOVED, info.removedPkgs[i]);
}
category.setChildren(children);
return category;
}
-
/**
* Creates the package category of the image delta. Returns
* the Delta object for the category. If there are no added,
@@ -613,17 +562,15 @@ class DeltaImpl implements IDelta {
protected IDelta createPackageCategory(DeltaImpl parent, DeltaInfo info) {
/* number of children of this category */
- int size =
- info.addedPkgs.length + info.changedPkgs.length + info.removedPkgs.length;
- if (size == 0)
- return null;
+ int size = info.addedPkgs.length + info.changedPkgs.length + info.removedPkgs.length;
+ if (size == 0) return null;
/* create the category */
- DeltaImpl category =
+ DeltaImpl category =
parent.add(
- fgPackageCategory,
- parent.getObject(),
- parent.getKey().add(fgPackageCategory),
+ fgPackageCategory,
+ parent.getObject(),
+ parent.getKey().add(fgPackageCategory),
CHANGED);
IDelta[] children = new IDelta[size];
@@ -636,10 +583,9 @@ class DeltaImpl implements IDelta {
}
for (int i = 0; i < info.changedPkgs.length; i++) {
IPackage pkg = info.changedPkgs[i].pkg;
- if (!Util
- .equalArraysOrNull(
- fOldState.getPackageMap().getFragments(pkg),
- fNewState.getPackageMap().getFragments(pkg))) {
+ if (!Util.equalArraysOrNull(
+ fOldState.getPackageMap().getFragments(pkg),
+ fNewState.getPackageMap().getFragments(pkg))) {
children[count++] = category.add(fgPackage, pkg, CHANGED);
}
}
@@ -648,7 +594,7 @@ class DeltaImpl implements IDelta {
if (count == 0) {
return null;
}
-
+
/* compact if some changed packages did not actually change */
if (count < children.length) {
System.arraycopy(children, 0, children = new IDelta[count], 0, count);
@@ -656,21 +602,18 @@ class DeltaImpl implements IDelta {
category.setChildren(children);
return category;
}
-
public void dump() {
dump(this, 0);
}
-
protected static void dump(IDelta delta, int depth) {
for (int i = 0; i < depth; ++i)
System.out.print(" ");
System.out.println(delta);
IDelta[] children = delta.getAffectedSubdeltas();
for (int i = 0; i < children.length; ++i) {
- dump(children[i], depth + 1);
+ dump(children[i], depth+1);
}
}
-
/**
* Returns the delta reached by navigating the given
* relative path from this object.
@@ -696,14 +639,12 @@ class DeltaImpl implements IDelta {
}
return delta;
}
-
/**
* Returns the immediate subdeltas of this delta that are additions
* (i.e. their status is Added).
*/
public IDelta[] getAddedSubdeltas() {
- if (fChildren == null)
- return fgEmptyArray;
+ if (fChildren == null) return fgEmptyArray;
Vector vAdded = new Vector();
for (int i = 0; i < fChildren.length; i++) {
if (fChildren[i].getStatus() == IDelta.ADDED) {
@@ -714,40 +655,33 @@ class DeltaImpl implements IDelta {
vAdded.copyInto(added);
return added;
}
-
- /**
- * Returns an enumeration of packages which are possibly affected.
- */
- public Enumeration getAffectedPackages() {
- /* Non-naive case - the image builder knows. */
- if (fIncrementalBuilder != null) {
- return fIncrementalBuilder.getAffectedPackages();
- }
-
- /* Naive case - take union of packages in old and new state. */
- Hashtable affected = new Hashtable(21);
- for (Enumeration e = fOldState.getPackageMap().getAllPackages();
- e.hasMoreElements();
- ) {
- IPackage pkg = (IPackage) e.nextElement();
- affected.put(pkg, pkg);
- }
- for (Enumeration e = fNewState.getPackageMap().getAllPackages();
- e.hasMoreElements();
- ) {
- IPackage pkg = (IPackage) e.nextElement();
- affected.put(pkg, pkg);
- }
- return affected.keys();
+/**
+ * Returns an enumeration of packages which are possibly affected.
+ */
+public Enumeration getAffectedPackages() {
+ /* Non-naive case - the image builder knows. */
+ if (fIncrementalBuilder != null) {
+ return fIncrementalBuilder.getAffectedPackages();
}
+ /* Naive case - take union of packages in old and new state. */
+ Hashtable affected = new Hashtable(21);
+ for (Enumeration e = fOldState.getPackageMap().getAllPackages(); e.hasMoreElements();) {
+ IPackage pkg = (IPackage) e.nextElement();
+ affected.put(pkg, pkg);
+ }
+ for (Enumeration e = fNewState.getPackageMap().getAllPackages(); e.hasMoreElements();) {
+ IPackage pkg = (IPackage) e.nextElement();
+ affected.put(pkg, pkg);
+ }
+ return affected.keys();
+}
/**
* Returns the immediate subdeltas of this delta that are
* not the same (i.e. their status is either Added, Removed, or Changed).
*/
public IDelta[] getAffectedSubdeltas() {
- if (fChildren == null)
- return fgEmptyArray;
+ if (fChildren == null) return fgEmptyArray;
Vector vAffected = new Vector();
for (int i = 0; i < fChildren.length; i++) {
if (fChildren[i].getStatus() != IDelta.SAME) {
@@ -758,14 +692,12 @@ class DeltaImpl implements IDelta {
vAffected.copyInto(affected);
return affected;
}
-
/**
* Returns the immediate subdeltas of this delta that are true
* changes, not additions or removals (i.e. their status is Changed).
*/
public IDelta[] getChangedSubdeltas() {
- if (fChildren == null)
- return fgEmptyArray;
+ if (fChildren == null) return fgEmptyArray;
Vector vChanged = new Vector();
for (int i = 0; i < fChildren.length; i++) {
if (fChildren[i].getStatus() == IDelta.CHANGED) {
@@ -776,7 +708,6 @@ class DeltaImpl implements IDelta {
vChanged.copyInto(changed);
return changed;
}
-
/**
* Returns the ImageContext that the delta is restricted to.
*
@@ -785,7 +716,6 @@ class DeltaImpl implements IDelta {
public IImageContext getImageContext() {
return fContext;
}
-
/**
* Returns the delta key for this delta.
* Delta keys often contain non-state-specific handles, but
@@ -796,14 +726,12 @@ class DeltaImpl implements IDelta {
public IDeltaKey getKey() {
return fKey;
}
-
/**
* Returns the name of the aspect being compared in this delta.
*/
public String getName() {
return fName;
}
-
/**
* Returns the object in the new state that is the focus of this delta.
* It only make sense to talk about the 'new object' if the object
@@ -815,21 +743,19 @@ class DeltaImpl implements IDelta {
public IHandle getNewObject() {
IHandle handle;
try {
- handle = (IHandle) fObject;
+ handle = (IHandle)fObject;
} catch (ClassCastException cce) {
//not a handle
return null;
}
return handle.inState(fNewState);
}
-
/**
* Returns the new state to which this delta pertains.
*/
public IState getNewState() {
return fNewState;
}
-
/**
* Returns the object that is the focus of this delta.
* The result is often a Handle, but in
@@ -839,7 +765,6 @@ class DeltaImpl implements IDelta {
public Object getObject() {
return fObject;
}
-
/**
* Returns the object in the old state that is the focus of this delta.
* It only make sense to talk about the 'old object' if the object
@@ -851,35 +776,31 @@ class DeltaImpl implements IDelta {
public IHandle getOldObject() {
IHandle handle;
try {
- handle = (IHandle) fObject;
+ handle = (IHandle)fObject;
} catch (ClassCastException cce) {
//not a handle
return null;
}
return handle.inState(fOldState);
}
-
/**
* Returns the old state to which this delta pertains.
*/
public org.eclipse.jdt.internal.core.builder.IState getOldState() {
return fOldState;
}
-
/**
* Returns the parent delta of this delta, or null if it has no parent.
*/
public IDelta getParent() {
return fParent;
}
-
/**
* Returns the immediate subdeltas of this delta that are removals
* (i.e. their status is Removed).
*/
public IDelta[] getRemovedSubdeltas() {
- if (fChildren == null)
- return fgEmptyArray;
+ if (fChildren == null) return fgEmptyArray;
Vector vRemoved = new Vector();
for (int i = 0; i < fChildren.length; i++) {
if (fChildren[i].getStatus() == IDelta.REMOVED) {
@@ -890,7 +811,6 @@ class DeltaImpl implements IDelta {
vRemoved.copyInto(removed);
return removed;
}
-
/**
* Returns the root delta of the tree containing this delta.
*/
@@ -902,7 +822,6 @@ class DeltaImpl implements IDelta {
return getParent().getRoot();
}
}
-
/**
* Returns the status of this delta. If this delta
* is not applicable, it always returns SAME.
@@ -912,7 +831,6 @@ class DeltaImpl implements IDelta {
public int getStatus() {
return fStatus;
}
-
/**
* Returns the status of this delta if it is known.
* Returns UNKNOWN if it is not known whether the object has changed.
@@ -921,7 +839,6 @@ class DeltaImpl implements IDelta {
public int getStatusIfKnown() {
return fStatus;
}
-
/**
* Returns an array of Delta objects that are children of this delta.
* Returns an array of length 0 if this delta has no children,
@@ -930,7 +847,6 @@ class DeltaImpl implements IDelta {
public IDelta[] getSubdeltas() {
return fChildren;
}
-
/**
* Returns whether this delta is a composite delta that is further
* broken down into subdeltas.
@@ -938,7 +854,6 @@ class DeltaImpl implements IDelta {
public boolean hasSubdeltas() {
return fChildren != null && fChildren.length > 0;
}
-
/**
* Creates a package delta for the types or binaries category.
* The package delta can be for either an added or removed package,
@@ -948,8 +863,8 @@ class DeltaImpl implements IDelta {
protected IDelta packageForTypeCategory(int status, PackageInfo info) {
/* create the package delta */
- DeltaImpl pkgDelta = (DeltaImpl) this.add(fgPackage, info.pkg, status);
-
+ DeltaImpl pkgDelta = (DeltaImpl)this.add(fgPackage, info.pkg, status);
+
IType[] types = (status == ADDED ? info.addedTypes : info.removedTypes);
IDelta[] children = new IDelta[types.length];
for (int i = 0; i < types.length; i++) {
@@ -958,14 +873,12 @@ class DeltaImpl implements IDelta {
pkgDelta.setChildren(children);
return pkgDelta;
}
-
/**
* Sets the children of this delta
*/
protected void setChildren(IDelta[] children) {
fChildren = children;
}
-
/**
* Return a string of the form:
* status key
@@ -983,29 +896,24 @@ class DeltaImpl implements IDelta {
public String toString() {
StringBuffer sb = new StringBuffer("DeltaImpl(");
switch (fStatus) {
- case ADDED :
- sb.append("+");
- break;
- case REMOVED :
- sb.append("-");
- break;
- case CHANGED :
- sb.append("*");
- break;
- case SAME :
- sb.append("=");
- break;
- case UNKNOWN :
- sb.append("?");
- break;
- default :
- sb.append("(ERROR)");
+ case ADDED: sb.append("+");
+ break;
+ case REMOVED: sb.append("-");
+ break;
+ case CHANGED: sb.append("*");
+ break;
+ case SAME: sb.append("=");
+ break;
+ case UNKNOWN: sb.append("?");
+ break;
+ default: sb.append("(ERROR)");
}
if (fKey.isRoot()) {
sb.append(fOldState);
sb.append("-->");
sb.append(fNewState);
- } else {
+ }
+ else {
for (int i = 0; i < fKey.size(); ++i) {
if (i != 0) {
sb.append('/');
@@ -1016,5 +924,4 @@ class DeltaImpl implements IDelta {
sb.append(')');
return sb.toString();
}
-
}

Back to the top