use of org.eclipse.jdt.core.IElementChangedListener in project che by eclipse.
the class DeltaProcessor method notifyTypeHierarchies.
private void notifyTypeHierarchies(IElementChangedListener[] listeners, int listenerCount) {
for (int i = 0; i < listenerCount; i++) {
final IElementChangedListener listener = listeners[i];
if (!(listener instanceof TypeHierarchy))
continue;
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
SafeRunner.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
//$NON-NLS-1$
Util.log(exception, "Exception occurred in listener of Java element change notification");
}
public void run() throws Exception {
TypeHierarchy typeHierarchy = (TypeHierarchy) listener;
if (typeHierarchy.hasFineGrainChanges()) {
// case of changes in primary working copies
typeHierarchy.needsRefresh = true;
typeHierarchy.fireChange();
}
}
});
}
}
use of org.eclipse.jdt.core.IElementChangedListener in project che by eclipse.
the class DeltaProcessor method fire.
/*
* Fire Java Model delta, flushing them after the fact after post_change notification.
* If the firing mode has been turned off, this has no effect.
*/
public void fire(IJavaElementDelta customDelta, int eventType) {
if (!this.isFiring)
return;
if (DEBUG) {
System.out.println(//$NON-NLS-1$
"-----------------------------------------------------------------------------------------------------------------------");
}
IJavaElementDelta deltaToNotify;
if (customDelta == null) {
deltaToNotify = mergeDeltas(this.javaModelDeltas);
} else {
deltaToNotify = customDelta;
}
// Refresh internal scopes
if (deltaToNotify != null) {
Iterator scopes = this.manager.searchScopes.keySet().iterator();
while (scopes.hasNext()) {
AbstractSearchScope scope = (AbstractSearchScope) scopes.next();
scope.processDelta(deltaToNotify, eventType);
}
JavaWorkspaceScope workspaceScope = this.manager.workspaceScope;
if (workspaceScope != null)
workspaceScope.processDelta(deltaToNotify, eventType);
}
// Notification
// Important: if any listener reacts to notification by updating the listeners list or mask, these lists will
// be duplicated, so it is necessary to remember original lists in a variable (since field values may change under us)
IElementChangedListener[] listeners;
int[] listenerMask;
int listenerCount;
synchronized (this.state) {
listeners = this.state.elementChangedListeners;
listenerMask = this.state.elementChangedListenerMasks;
listenerCount = this.state.elementChangedListenerCount;
}
switch(eventType) {
case DEFAULT_CHANGE_EVENT:
case ElementChangedEvent.POST_CHANGE:
firePostChangeDelta(deltaToNotify, listeners, listenerMask, listenerCount);
fireReconcileDelta(listeners, listenerMask, listenerCount);
break;
}
}
use of org.eclipse.jdt.core.IElementChangedListener in project che by eclipse.
the class DeltaProcessor method notifyListeners.
private void notifyListeners(IJavaElementDelta deltaToNotify, int eventType, IElementChangedListener[] listeners, int[] listenerMask, int listenerCount) {
final ElementChangedEvent extraEvent = new ElementChangedEvent(deltaToNotify, eventType);
for (int i = 0; i < listenerCount; i++) {
if ((listenerMask[i] & eventType) != 0) {
final IElementChangedListener listener = listeners[i];
long start = -1;
if (VERBOSE) {
//$NON-NLS-1$//$NON-NLS-2$
System.out.print("Listener #" + (i + 1) + "=" + listener.toString());
start = System.currentTimeMillis();
}
// wrap callbacks with Safe runnable for subsequent listeners to be called when some are causing grief
SafeRunner.run(new ISafeRunnable() {
public void handleException(Throwable exception) {
//$NON-NLS-1$
Util.log(exception, "Exception occurred in listener of Java element change notification");
}
public void run() throws Exception {
PerformanceStats stats = null;
if (PERF) {
// stats = PerformanceStats.getStats(JavaModelManager.DELTA_LISTENER_PERF, listener);
// stats.startRun();
}
listener.elementChanged(extraEvent);
if (PERF) {
stats.endRun();
}
}
});
if (VERBOSE) {
//$NON-NLS-1$ //$NON-NLS-2$
System.out.println(" -> " + (System.currentTimeMillis() - start) + "ms");
}
}
}
}
use of org.eclipse.jdt.core.IElementChangedListener in project che by eclipse.
the class DeltaProcessor method resourceChanged.
/*
* Notification that some resource changes have happened
* on the platform, and that the Java Model should update any required
* internal structures such that its elements remain consistent.
* Translates <code>IResourceDeltas</code> into <code>IJavaElementDeltas</code>.
*
* @see IResourceDelta
* @see IResource
*/
public void resourceChanged(IResourceChangeEvent event) {
int eventType = this.overridenEventType == -1 ? event.getType() : this.overridenEventType;
IResource resource = event.getResource();
IResourceDelta delta = (IResourceDelta) event.getDelta();
switch(eventType) {
case IResourceChangeEvent.PRE_DELETE:
// }
return;
case IResourceChangeEvent.PRE_REFRESH:
// }
return;
case IResourceChangeEvent.POST_CHANGE:
HashSet elementsToRefresh = this.state.removeExternalElementsToRefresh();
if (// avoid populating for SYNC or MARKER deltas
isAffectedBy(delta) || elementsToRefresh != null) {
try {
try {
stopDeltas();
checkProjectsAndClasspathChanges(delta);
// generate external archive change deltas
if (elementsToRefresh != null) {
createExternalArchiveDelta(elementsToRefresh, null);
}
// generate classpath change deltas
HashMap classpathChanges = this.state.removeAllClasspathChanges();
// if (classpathChanges.size() > 0) {
// boolean hasDelta = this.currentDelta != null;
// JavaElementDelta javaDelta = currentDelta();
// Iterator changes = classpathChanges.values().iterator();
// while (changes.hasNext()) {
// ClasspathChange change = (ClasspathChange) changes.next();
// int result = change.generateDelta(javaDelta, false/*don't add classpath change*/);
// if ((result & ClasspathChange.HAS_DELTA) != 0) {
// hasDelta = true;
//
// // need to recompute root infos
// this.state.rootsAreStale = true;
//
// change.requestIndexing();
// this.state.addClasspathValidation(change.project);
// }
// if ((result & ClasspathChange.HAS_PROJECT_CHANGE) != 0) {
// this.state.addProjectReferenceChange(change.project, change.oldResolvedClasspath);
// }
// if ((result & ClasspathChange.HAS_LIBRARY_CHANGE) != 0) {
// this.state.addExternalFolderChange(change.project, change.oldResolvedClasspath);
// }
// }
// // process late coming external elements to refresh (see https://bugs.eclipse.org/bugs/show_bug
// .cgi?id=212769 )
// elementsToRefresh = this.state.removeExternalElementsToRefresh();
// if (elementsToRefresh != null) {
// hasDelta |= createExternalArchiveDelta(elementsToRefresh, null);
// }
// if (!hasDelta)
// this.currentDelta = null;
// }
// generate Java deltas from resource changes
IJavaElementDelta translatedDelta = processResourceDelta(delta);
if (translatedDelta != null) {
registerJavaModelDelta(translatedDelta);
}
} finally {
// don't hold onto parser longer than necessary
this.sourceElementParserCache = null;
startDeltas();
}
IElementChangedListener[] listeners;
int listenerCount;
synchronized (this.state) {
listeners = this.state.elementChangedListeners;
listenerCount = this.state.elementChangedListenerCount;
}
notifyTypeHierarchies(listeners, listenerCount);
fire(null, ElementChangedEvent.POST_CHANGE);
} finally {
// workaround for bug 15168 circular errors not reported
this.state.resetOldJavaProjectNames();
this.oldRoots = null;
}
}
return;
case IResourceChangeEvent.PRE_BUILD:
// does not fire any deltas
return;
case IResourceChangeEvent.POST_BUILD:
// JavaBuilder.buildFinished();
return;
}
}
Aggregations