/** * Notify the listeners that this buffer has changed. * To avoid deadlock, this should not be called in a synchronized block. */ protected void notifyChanged(final BufferChangedEvent event) { ListenerList<IBufferChangedListener> listeners = this.changeListeners; if (listeners != null) { Iterator<IBufferChangedListener> iterator = listeners.iterator(); while (iterator.hasNext()) { final IBufferChangedListener listener = iterator.next(); SafeRunner.run(new ISafeRunnable() { @Override public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification"); //$NON-NLS-1$ } @Override public void run() throws Exception { listener.bufferChanged(event); } }); } } } /**
/** * Notify the listeners that this buffer has changed. * To avoid deadlock, this should not be called in a synchronized block. */ protected void notifyChanged(final BufferChangedEvent event) { ListenerList<IBufferChangedListener> listeners = this.changeListeners; if (listeners != null) { Iterator<IBufferChangedListener> iterator = listeners.iterator(); while (iterator.hasNext()) { final IBufferChangedListener listener = iterator.next(); SafeRunner.run(new ISafeRunnable() { public void handleException(Throwable exception) { Util.log(exception, "Exception occurred in listener of buffer change notification"); //$NON-NLS-1$ } public void run() throws Exception { listener.bufferChanged(event); } }); } } } /**
protected final IStatus calculateASTandInform(ITypeRoot input, ITextSelection selection, IProgressMonitor monitor) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // create AST try { CompilationUnit astRoot= SharedASTProvider.getAST(input, SharedASTProvider.WAIT_ACTIVE_ONLY, monitor); if (astRoot != null && !monitor.isCanceled()) { Iterator<ISelectionListenerWithAST> listeners; synchronized (PartListenerGroup.this) { // sync probably doesn't make sense here... listeners= fAstListeners.iterator(); } while (listeners.hasNext()) { ISelectionListenerWithAST listener= listeners.next(); listener.selectionChanged(fPart, selection, astRoot); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } } catch (OperationCanceledException e) { // thrown when canceling the AST creation } return Status.CANCEL_STATUS; } }
protected final IStatus calculateASTandInform(ITypeRoot input, ITextSelection selection, IProgressMonitor monitor) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } // create AST try { CompilationUnit astRoot= SharedASTProviderCore.getAST(input, SharedASTProviderCore.WAIT_ACTIVE_ONLY, monitor); if (astRoot != null && !monitor.isCanceled()) { Iterator<ISelectionListenerWithAST> listeners; synchronized (PartListenerGroup.this) { // sync probably doesn't make sense here... listeners= fAstListeners.iterator(); } while (listeners.hasNext()) { ISelectionListenerWithAST listener= listeners.next(); listener.selectionChanged(fPart, selection, astRoot); if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } } return Status.OK_STATUS; } } catch (OperationCanceledException e) { // thrown when canceling the AST creation } return Status.CANCEL_STATUS; } }