use of org.eclipse.core.runtime.OperationCanceledException in project xtext-core by eclipse.
the class ReferenceFinder method findReferences.
@Override
public void findReferences(TargetURIs targetURIs, Set<URI> candidates, IResourceAccess resourceAccess, IResourceDescriptions descriptions, Acceptor acceptor, IProgressMonitor monitor) {
if (!targetURIs.isEmpty() && !candidates.isEmpty()) {
SubMonitor subMonitor = SubMonitor.convert(monitor, targetURIs.size() / MONITOR_CHUNK_SIZE + 1);
IProgressMonitor useMe = subMonitor.newChild(1);
int i = 0;
for (URI candidate : candidates) {
if (subMonitor.isCanceled())
throw new OperationCanceledException();
IReferenceFinder languageSpecific = getLanguageSpecificReferenceFinder(candidate);
doFindReferencesWith(languageSpecific, targetURIs, candidate, resourceAccess, descriptions, acceptor, useMe);
i++;
if (i % MONITOR_CHUNK_SIZE == 0) {
useMe = subMonitor.newChild(1);
}
}
}
}
use of org.eclipse.core.runtime.OperationCanceledException in project xtext-core by eclipse.
the class FileSystemAccessQueue method send.
protected FileSystemAccessRequest send(final FileSystemAccessRequest request) {
try {
boolean _isCanceled = this.monitor.isCanceled();
if (_isCanceled) {
throw new OperationCanceledException();
}
this.requestQueue.put(request);
return request;
} catch (final Throwable _t) {
if (_t instanceof InterruptedException) {
throw new OperationCanceledException();
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class CheckConditionsContext method check.
/**
* Checks the condition of all registered condition checkers and returns a
* merge status result.
*
* @param pm a progress monitor or <code>null</code> if no progress
* reporting is desired
*
* @return the combined status result
*
* @throws CoreException if an error occurs during condition checking
*/
public RefactoringStatus check(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
RefactoringStatus result = new RefactoringStatus();
mergeResourceOperationAndValidateEdit();
List values = new ArrayList(fCheckers.values());
Collections.sort(values, new Comparator() {
public int compare(Object o1, Object o2) {
// ResourceOperationChecker
if (o1 instanceof ResourceChangeChecker)
return -1;
if (o2 instanceof ResourceChangeChecker)
return 1;
return 0;
}
});
//$NON-NLS-1$
pm.beginTask("", values.size());
for (Iterator iter = values.iterator(); iter.hasNext(); ) {
IConditionChecker checker = (IConditionChecker) iter.next();
result.merge(checker.check(new SubProgressMonitor(pm, 1)));
if (pm.isCanceled())
throw new OperationCanceledException();
}
return result;
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class ProcessorBasedRefactoring method checkFinalConditions.
/**
* {@inheritDoc}
*/
public RefactoringStatus checkFinalConditions(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
RefactoringStatus result = new RefactoringStatus();
CheckConditionsContext context = createCheckConditionsContext();
//$NON-NLS-1$
pm.beginTask("", 9);
pm.setTaskName(RefactoringCoreMessages.ProcessorBasedRefactoring_final_conditions);
result.merge(getProcessor().checkFinalConditions(new SubProgressMonitor(pm, 5), context));
if (result.hasFatalError()) {
pm.done();
return result;
}
if (pm.isCanceled())
throw new OperationCanceledException();
// must not be shared when checkFinalConditions is called again
SharableParticipants sharableParticipants = new SharableParticipants();
RefactoringParticipant[] loadedParticipants = getProcessor().loadParticipants(result, sharableParticipants);
if (loadedParticipants == null || loadedParticipants.length == 0) {
fParticipants = EMPTY_PARTICIPANTS;
} else {
fParticipants = new ArrayList();
for (int i = 0; i < loadedParticipants.length; i++) {
fParticipants.add(loadedParticipants[i]);
}
}
if (result.hasFatalError()) {
pm.done();
return result;
}
IProgressMonitor sm = new SubProgressMonitor(pm, 2);
//$NON-NLS-1$
sm.beginTask("", fParticipants.size());
for (Iterator iter = fParticipants.iterator(); iter.hasNext() && !result.hasFatalError(); ) {
RefactoringParticipant participant = (RefactoringParticipant) iter.next();
//$NON-NLS-1$
final PerformanceStats stats = PerformanceStats.getStats(PERF_CHECK_CONDITIONS, getName() + ", " + participant.getName());
stats.startRun();
try {
result.merge(participant.checkConditions(new SubProgressMonitor(sm, 1), context));
} catch (OperationCanceledException e) {
throw e;
} catch (RuntimeException e) {
// remove the participant so that it will be ignored during change execution.
RefactoringCorePlugin.log(e);
result.merge(RefactoringStatus.createErrorStatus(Messages.format(RefactoringCoreMessages.ProcessorBasedRefactoring_check_condition_participant_failed, participant.getName())));
iter.remove();
}
stats.endRun();
if (sm.isCanceled())
throw new OperationCanceledException();
}
sm.done();
if (result.hasFatalError()) {
pm.done();
return result;
}
result.merge(context.check(new SubProgressMonitor(pm, 1)));
pm.done();
return result;
}
use of org.eclipse.core.runtime.OperationCanceledException in project che by eclipse.
the class PerformChangeOperation method run.
/**
* {@inheritDoc}
*/
public void run(IProgressMonitor pm) throws CoreException {
if (pm == null)
pm = new NullProgressMonitor();
try {
fChangeExecuted = false;
if (createChange()) {
//$NON-NLS-1$
pm.beginTask("", 4);
//$NON-NLS-1$
pm.subTask("");
fCreateChangeOperation.run(new SubProgressMonitor(pm, 3));
// (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=187265 ):
if (pm.isCanceled())
throw new OperationCanceledException();
fChange = fCreateChangeOperation.getChange();
if (fChange != null) {
executeChange(new SubProgressMonitor(pm, 1));
} else {
pm.worked(1);
}
} else {
executeChange(pm);
}
} finally {
pm.done();
}
}
Aggregations