use of org.eclipse.core.runtime.ISafeRunnable in project che by eclipse.
the class ASTProvider method createAST.
/**
* Creates a new compilation unit AST.
*
* @param input the Java element for which to create the AST
* @param progressMonitor the progress monitor
* @return AST
*/
public static CompilationUnit createAST(final ITypeRoot input, final IProgressMonitor progressMonitor) {
if (!hasSource(input))
return null;
if (progressMonitor != null && progressMonitor.isCanceled())
return null;
final CheASTParser parser = CheASTParser.newParser(SHARED_AST_LEVEL);
parser.setResolveBindings(true);
parser.setStatementsRecovery(SHARED_AST_STATEMENT_RECOVERY);
parser.setBindingsRecovery(SHARED_BINDING_RECOVERY);
parser.setSource(input);
if (progressMonitor != null && progressMonitor.isCanceled())
return null;
final CompilationUnit[] root = new CompilationUnit[1];
SafeRunner.run(new ISafeRunnable() {
public void run() {
try {
if (progressMonitor != null && progressMonitor.isCanceled())
return;
if (DEBUG)
System.err.println(getThreadName() + " - " + DEBUG_PREFIX + "creating AST for: " + //$NON-NLS-1$ //$NON-NLS-2$
input.getElementName());
root[0] = (CompilationUnit) parser.createAST(progressMonitor);
//mark as unmodifiable
ASTNodes.setFlagsToAST(root[0], ASTNode.PROTECT);
} catch (OperationCanceledException ex) {
return;
}
}
public void handleException(Throwable ex) {
LOG.error(ex.getMessage(), ex);
}
});
return root[0];
}
use of org.eclipse.core.runtime.ISafeRunnable in project che by eclipse.
the class RefactoringHistoryService method fireRefactoringHistoryEvent.
private void fireRefactoringHistoryEvent(final RefactoringDescriptorProxy proxy, final int eventType) {
Assert.isNotNull(proxy);
final Object[] listeners = fHistoryListeners.getListeners();
for (int index = 0; index < listeners.length; index++) {
final IRefactoringHistoryListener listener = (IRefactoringHistoryListener) listeners[index];
SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
}
public void run() throws Exception {
listener.historyNotification(new RefactoringHistoryEvent(RefactoringHistoryService.this, eventType, proxy));
}
});
}
}
use of org.eclipse.core.runtime.ISafeRunnable in project che by eclipse.
the class RefactoringHistoryService method fireRefactoringExecutionEvent.
private void fireRefactoringExecutionEvent(final RefactoringDescriptorProxy proxy, final int eventType) {
Assert.isNotNull(proxy);
final Object[] listeners = fExecutionListeners.getListeners();
for (int index = 0; index < listeners.length; index++) {
final IRefactoringExecutionListener listener = (IRefactoringExecutionListener) listeners[index];
SafeRunner.run(new ISafeRunnable() {
public void handleException(final Throwable throwable) {
RefactoringCorePlugin.log(throwable);
}
public void run() throws Exception {
listener.executionNotification(new RefactoringExecutionEvent(RefactoringHistoryService.this, eventType, proxy));
}
});
}
}
use of org.eclipse.core.runtime.ISafeRunnable in project che by eclipse.
the class UndoManager2 method fireChangePerformed.
private void fireChangePerformed(final Change change) {
if (fListeners == null)
return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
listener.changePerformed(UndoManager2.this, change);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
use of org.eclipse.core.runtime.ISafeRunnable in project che by eclipse.
the class UndoManager2 method fireRedoStackChanged.
private void fireRedoStackChanged() {
if (fListeners == null)
return;
Object[] listeners = fListeners.getListeners();
for (int i = 0; i < listeners.length; i++) {
final IUndoManagerListener listener = (IUndoManagerListener) listeners[i];
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
listener.redoStackChanged(UndoManager2.this);
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
}
Aggregations