Search in sources :

Example 1 with ElementChangedEvent

use of org.eclipse.jdt.core.ElementChangedEvent 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");
            }
        }
    }
}
Also used : PerformanceStats(org.eclipse.core.runtime.PerformanceStats) IElementChangedListener(org.eclipse.jdt.core.IElementChangedListener) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) JavaModelException(org.eclipse.jdt.core.JavaModelException) CoreException(org.eclipse.core.runtime.CoreException) ElementChangedEvent(org.eclipse.jdt.core.ElementChangedEvent)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 ISafeRunnable (org.eclipse.core.runtime.ISafeRunnable)1 PerformanceStats (org.eclipse.core.runtime.PerformanceStats)1 ElementChangedEvent (org.eclipse.jdt.core.ElementChangedEvent)1 IElementChangedListener (org.eclipse.jdt.core.IElementChangedListener)1 JavaModelException (org.eclipse.jdt.core.JavaModelException)1