import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.Platform;
+//import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
/**
* Keep the global states used during Java element delta processing.
* is reacting to some notification iteration by adding/changing/removing
* any of the other (for example, if it deregisters itself).
*/
- public void addElementChangedListener(IElementChangedListener listener,
- int eventMask) {
- for (int i = 0; i < this.elementChangedListenerCount; i++) {
- if (this.elementChangedListeners[i].equals(listener)) {
-
- // only clone the masks, since we could be in the middle of
- // notifications and one listener decide to change
- // any event mask of another listeners (yet not notified).
- int cloneLength = this.elementChangedListenerMasks.length;
- System
- .arraycopy(
- this.elementChangedListenerMasks,
- 0,
- this.elementChangedListenerMasks = new int[cloneLength],
- 0, cloneLength);
- this.elementChangedListenerMasks[i] = eventMask; // could be
- // different
- return;
- }
- }
- // may need to grow, no need to clone, since iterators will have cached
- // original arrays and max boundary and we only add to the end.
- int length;
- if ((length = this.elementChangedListeners.length) == this.elementChangedListenerCount) {
- System
- .arraycopy(
- this.elementChangedListeners,
- 0,
- this.elementChangedListeners = new IElementChangedListener[length * 2],
- 0, length);
- System.arraycopy(this.elementChangedListenerMasks, 0,
- this.elementChangedListenerMasks = new int[length * 2], 0,
- length);
- }
- this.elementChangedListeners[this.elementChangedListenerCount] = listener;
- this.elementChangedListenerMasks[this.elementChangedListenerCount] = eventMask;
- this.elementChangedListenerCount++;
- }
+// public void addElementChangedListener(IElementChangedListener listener,
+// int eventMask) {
+// for (int i = 0; i < this.elementChangedListenerCount; i++) {
+// if (this.elementChangedListeners[i].equals(listener)) {
+//
+// // only clone the masks, since we could be in the middle of
+// // notifications and one listener decide to change
+// // any event mask of another listeners (yet not notified).
+// int cloneLength = this.elementChangedListenerMasks.length;
+// System
+// .arraycopy(
+// this.elementChangedListenerMasks,
+// 0,
+// this.elementChangedListenerMasks = new int[cloneLength],
+// 0, cloneLength);
+// this.elementChangedListenerMasks[i] = eventMask; // could be
+// // different
+// return;
+// }
+// }
+// // may need to grow, no need to clone, since iterators will have cached
+// // original arrays and max boundary and we only add to the end.
+// int length;
+// if ((length = this.elementChangedListeners.length) == this.elementChangedListenerCount) {
+// System
+// .arraycopy(
+// this.elementChangedListeners,
+// 0,
+// this.elementChangedListeners = new IElementChangedListener[length * 2],
+// 0, length);
+// System.arraycopy(this.elementChangedListenerMasks, 0,
+// this.elementChangedListenerMasks = new int[length * 2], 0,
+// length);
+// }
+// this.elementChangedListeners[this.elementChangedListenerCount] = listener;
+// this.elementChangedListenerMasks[this.elementChangedListenerCount] = eventMask;
+// this.elementChangedListenerCount++;
+// }
public void addPreResourceChangedListener(IResourceChangeListener listener) {
for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
return deltaProcessor;
}
- public void performClasspathResourceChange(JavaProject project,
- IClasspathEntry[] oldResolvedPath,
- IClasspathEntry[] newResolvedPath, IClasspathEntry[] newRawPath,
- boolean canChangeResources) throws JavaModelException {
- ProjectUpdateInfo info = new ProjectUpdateInfo();
- info.project = project;
- info.oldResolvedPath = oldResolvedPath;
- info.newResolvedPath = newResolvedPath;
- info.newRawPath = newRawPath;
- if (canChangeResources) {
- this.projectUpdates.remove(project); // remove possibly awaiting
- // one
- info.updateProjectReferencesIfNecessary();
- return;
- }
- this.recordProjectUpdate(info);
- }
+// public void performClasspathResourceChange(JavaProject project,
+// IClasspathEntry[] oldResolvedPath,
+// IClasspathEntry[] newResolvedPath, IClasspathEntry[] newRawPath,
+// boolean canChangeResources) throws JavaModelException {
+// ProjectUpdateInfo info = new ProjectUpdateInfo();
+// info.project = project;
+// info.oldResolvedPath = oldResolvedPath;
+// info.newResolvedPath = newResolvedPath;
+// info.newRawPath = newRawPath;
+// if (canChangeResources) {
+// this.projectUpdates.remove(project); // remove possibly awaiting
+// // one
+// info.updateProjectReferencesIfNecessary();
+// return;
+// }
+// this.recordProjectUpdate(info);
+// }
public void initializeRoots() {
return;
}
for (int i = 0, length = projects.length; i < length; i++) {
- JavaProject project = (JavaProject) projects[i];
+ //JavaProject project = (JavaProject) projects[i];
// IClasspathEntry[] classpath;
// try {
// classpath =
}
}
- public synchronized void recordProjectUpdate(ProjectUpdateInfo newInfo) {
-
- JavaProject project = newInfo.project;
- ProjectUpdateInfo oldInfo = (ProjectUpdateInfo) this.projectUpdates
- .get(project);
- if (oldInfo != null) { // refresh new classpath information
- oldInfo.newRawPath = newInfo.newRawPath;
- oldInfo.newResolvedPath = newInfo.newResolvedPath;
- } else {
- this.projectUpdates.put(project, newInfo);
- }
- }
+// public synchronized void recordProjectUpdate(ProjectUpdateInfo newInfo) {
+//
+// JavaProject project = newInfo.project;
+// ProjectUpdateInfo oldInfo = (ProjectUpdateInfo) this.projectUpdates
+// .get(project);
+// if (oldInfo != null) { // refresh new classpath information
+// oldInfo.newRawPath = newInfo.newRawPath;
+// oldInfo.newResolvedPath = newInfo.newResolvedPath;
+// } else {
+// this.projectUpdates.put(project, newInfo);
+// }
+// }
public synchronized ProjectUpdateInfo[] removeAllProjectUpdates() {
int length = this.projectUpdates.size();
return updates;
}
- public void removeElementChangedListener(IElementChangedListener listener) {
-
- for (int i = 0; i < this.elementChangedListenerCount; i++) {
-
- if (this.elementChangedListeners[i].equals(listener)) {
-
- // need to clone defensively since we might be in the middle of
- // listener notifications (#fire)
- int length = this.elementChangedListeners.length;
- IElementChangedListener[] newListeners = new IElementChangedListener[length];
- System.arraycopy(this.elementChangedListeners, 0, newListeners,
- 0, i);
- int[] newMasks = new int[length];
- System.arraycopy(this.elementChangedListenerMasks, 0, newMasks,
- 0, i);
-
- // copy trailing listeners
- int trailingLength = this.elementChangedListenerCount - i - 1;
- if (trailingLength > 0) {
- System.arraycopy(this.elementChangedListeners, i + 1,
- newListeners, i, trailingLength);
- System.arraycopy(this.elementChangedListenerMasks, i + 1,
- newMasks, i, trailingLength);
- }
-
- // update manager listener state (#fire need to iterate over
- // original listeners through a local variable to hold onto
- // the original ones)
- this.elementChangedListeners = newListeners;
- this.elementChangedListenerMasks = newMasks;
- this.elementChangedListenerCount--;
- return;
- }
- }
- }
-
- public void removePreResourceChangedListener(
- IResourceChangeListener listener) {
-
- for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
-
- if (this.preResourceChangeListeners[i].equals(listener)) {
-
- // need to clone defensively since we might be in the middle of
- // listener notifications (#fire)
- int length = this.preResourceChangeListeners.length;
- IResourceChangeListener[] newListeners = new IResourceChangeListener[length];
- System.arraycopy(this.preResourceChangeListeners, 0,
- newListeners, 0, i);
-
- // copy trailing listeners
- int trailingLength = this.preResourceChangeListenerCount - i
- - 1;
- if (trailingLength > 0) {
- System.arraycopy(this.preResourceChangeListeners, i + 1,
- newListeners, i, trailingLength);
- }
-
- // update manager listener state (#fire need to iterate over
- // original listeners through a local variable to hold onto
- // the original ones)
- this.preResourceChangeListeners = newListeners;
- this.preResourceChangeListenerCount--;
- return;
- }
- }
- }
+// public void removeElementChangedListener(IElementChangedListener listener) {
+//
+// for (int i = 0; i < this.elementChangedListenerCount; i++) {
+//
+// if (this.elementChangedListeners[i].equals(listener)) {
+//
+// // need to clone defensively since we might be in the middle of
+// // listener notifications (#fire)
+// int length = this.elementChangedListeners.length;
+// IElementChangedListener[] newListeners = new IElementChangedListener[length];
+// System.arraycopy(this.elementChangedListeners, 0, newListeners,
+// 0, i);
+// int[] newMasks = new int[length];
+// System.arraycopy(this.elementChangedListenerMasks, 0, newMasks,
+// 0, i);
+//
+// // copy trailing listeners
+// int trailingLength = this.elementChangedListenerCount - i - 1;
+// if (trailingLength > 0) {
+// System.arraycopy(this.elementChangedListeners, i + 1,
+// newListeners, i, trailingLength);
+// System.arraycopy(this.elementChangedListenerMasks, i + 1,
+// newMasks, i, trailingLength);
+// }
+//
+// // update manager listener state (#fire need to iterate over
+// // original listeners through a local variable to hold onto
+// // the original ones)
+// this.elementChangedListeners = newListeners;
+// this.elementChangedListenerMasks = newMasks;
+// this.elementChangedListenerCount--;
+// return;
+// }
+// }
+// }
+
+// public void removePreResourceChangedListener(
+// IResourceChangeListener listener) {
+//
+// for (int i = 0; i < this.preResourceChangeListenerCount; i++) {
+//
+// if (this.preResourceChangeListeners[i].equals(listener)) {
+//
+// // need to clone defensively since we might be in the middle of
+// // listener notifications (#fire)
+// int length = this.preResourceChangeListeners.length;
+// IResourceChangeListener[] newListeners = new IResourceChangeListener[length];
+// System.arraycopy(this.preResourceChangeListeners, 0,
+// newListeners, 0, i);
+//
+// // copy trailing listeners
+// int trailingLength = this.preResourceChangeListenerCount - i
+// - 1;
+// if (trailingLength > 0) {
+// System.arraycopy(this.preResourceChangeListeners, i + 1,
+// newListeners, i, trailingLength);
+// }
+//
+// // update manager listener state (#fire need to iterate over
+// // original listeners through a local variable to hold onto
+// // the original ones)
+// this.preResourceChangeListeners = newListeners;
+// this.preResourceChangeListenerCount--;
+// return;
+// }
+// }
+// }
public void resourceChanged(final IResourceChangeEvent event) {
boolean isPostChange = event.getType() == IResourceChangeEvent.POST_CHANGE;
// wrap callbacks with Safe runnable for subsequent listeners to
// be called when some are causing grief
final IResourceChangeListener listener = this.preResourceChangeListeners[i];
- Platform.run(new ISafeRunnable() {
+ SafeRunner.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
Util
.log(exception,