use of org.eclipse.core.runtime.OperationCanceledException in project AutoRefactor by JnRouvignac.
the class AggregateASTVisitor method logFaultyVisitor.
private void logFaultyVisitor(ASTVisitor v, ASTNode node, Exception e) {
if (e instanceof OperationCanceledException) {
// let the user cancel the current operation
throw (OperationCanceledException) e;
}
String message = "Visitor " + v.getClass().getName() + " is faulty," + " it will be disabled for the rest of this run.";
ctx.getLogger().error(message, new UnhandledException(node, message, e));
}
use of org.eclipse.core.runtime.OperationCanceledException in project xtext-xtend by eclipse.
the class ExtractMethodRefactoring method checkFinalConditions.
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
StatusWrapper status = statusProvider.get();
try {
status.merge(validateMethodName(methodName));
status.merge(validateParameters());
ITextRegion expressionsRegion = getExpressionsRegion();
ITextRegion predecessorRegion = locationInFileProvider.getFullTextRegion(originalMethod);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
Section expressionSection = rewriter.newSection(expressionsRegion.getOffset(), expressionsRegion.getLength());
Section declarationSection = rewriter.newSection(predecessorRegion.getOffset() + predecessorRegion.getLength(), 0);
createMethodCallEdit(expressionSection, expressionsRegion);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
createMethodDeclarationEdit(declarationSection, expressionSection.getBaseIndentLevel(), expressionsRegion);
if (pm.isCanceled()) {
throw new OperationCanceledException();
}
textEdit = replaceConverter.convertToTextEdit(rewriter.getChanges());
} catch (OperationCanceledException e) {
throw e;
} catch (Exception exc) {
handleException(exc, status);
}
return status.getRefactoringStatus();
}
use of org.eclipse.core.runtime.OperationCanceledException in project xtext-xtend by eclipse.
the class OverrideIndicatorModelListener method asyncUpdateAnnotationModel.
private void asyncUpdateAnnotationModel() {
if (currentJob != null) {
currentJob.cancel();
}
currentJob = new Job(JOB_NAME) {
@Override
public IStatus run(IProgressMonitor monitor) {
try {
return updateAnnotationModel(monitor);
} catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
} catch (Exception e) {
LOG.error("Error updating override indicator", e);
return Status.OK_STATUS;
}
}
};
currentJob.setRule(SCHEDULING_RULE);
currentJob.setPriority(Job.DECORATE);
currentJob.setSystem(true);
currentJob.schedule();
}
use of org.eclipse.core.runtime.OperationCanceledException in project linuxtools by eclipse.
the class AbstractTest method buildProject.
protected void buildProject(IProject proj) throws CoreException {
IWorkspace wsp = ResourcesPlugin.getWorkspace();
final IProject curProject = proj;
ISchedulingRule rule = wsp.getRuleFactory().buildRule();
Job buildJob = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"project build job") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
curProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
} catch (CoreException e) {
fail(e.getStatus().getMessage());
} catch (OperationCanceledException e) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_cancelled"), curProject.getName(), // $NON-NLS-1$
e.getMessage()));
}
return Status.OK_STATUS;
}
};
buildJob.setRule(rule);
buildJob.schedule();
try {
buildJob.join();
} catch (InterruptedException e) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_interrupted"), curProject.getName(), // $NON-NLS-1$
e.getMessage()));
}
IStatus status = buildJob.getResult();
if (status.getCode() != IStatus.OK) {
fail(NLS.bind(Messages.getString("AbstractTest.Build_failed"), curProject.getName(), // $NON-NLS-1$
status.getMessage()));
}
IWorkspaceRunnable runnable = monitor -> curProject.refreshLocal(IResource.DEPTH_INFINITE, null);
wsp.run(runnable, wsp.getRoot(), IWorkspace.AVOID_UPDATE, null);
}
use of org.eclipse.core.runtime.OperationCanceledException in project linuxtools by eclipse.
the class ChangeLogAction method createChangeLog.
protected IFile createChangeLog(IPath changelog) {
IWorkspaceRoot myWorkspaceRoot = getWorkspaceRoot();
IWorkbench ws = PlatformUI.getWorkbench();
final IFile changelog_File = myWorkspaceRoot.getFile(changelog);
final InputStream initialContents = new ByteArrayInputStream(new byte[0]);
WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
@Override
public void execute(IProgressMonitor monitor) throws CoreException {
try {
// $NON-NLS-1$
monitor.beginTask(Messages.getString("ChangeLog.AddingChangeLog"), 2000);
changelog_File.create(initialContents, false, monitor);
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
} finally {
monitor.done();
}
}
};
try {
new ProgressMonitorDialog(ws.getActiveWorkbenchWindow().getShell()).run(true, true, operation);
} catch (InterruptedException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrInterrupted"), e);
return null;
} catch (InvocationTargetException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrInvocation"), e);
return null;
}
// FIXME: we should put this refreshLocal call into a thread (filed as bug #256180)
try {
IContainer changelogContainer = myWorkspaceRoot.getContainerForLocation(changelog);
if (changelogContainer != null)
changelogContainer.refreshLocal(2, null);
} catch (CoreException e) {
// $NON-NLS-1$
reportErr(Messages.getString("ChangeLog.ErrRefresh"), e);
return null;
}
return changelog_File;
}
Aggregations