Bug 47010 Make refactorings more responsive to cancel [refactoring]
I20031119 Most of our current refactorings only do a sporadic check of IProgressMonitor.isCanceled() resulting in a bad canceling behavior. We should make a path over our existing refactoring and queck the cancel state at least after each compilation unit we have processes in checkInput and createChange. The code pattern to add should look like this: pm.worked(...) if (pm.isCanceled()) { // clean-up state if necessary throw new OperationCancelException(); }
org.eclipse.ltk.core.refactoring/src/org/eclipse/ltk/core/refactoring/participants/ProcessorBasedRefactoring.java
import org.eclipse.ltk.internal.core.refactoring.RefactoringCoreMessages;
import org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin;
/**
 * An abstract base implementation for refactorings that are split into
 * one refactoring processor and 0..n participants.
 * <p>
 * This class should be subclassed by clients wishing to provide a special
 * refactoring which uses a processor/participant architecture.
 * </p>
 * @since 3.0 
 */
public abstract class ProcessorBasedRefactoring extends Refactoring {
	
	private RefactoringParticipant[] fParticipants;
	private SharableParticipants fSharedParticipants= new SharableParticipants();
	
	private static final RefactoringParticipant[] EMPTY_PARTICIPANTS= new RefactoringParticipant[0];
	private static class ProcessorChange extends CompositeChange {
		private Map fParticipantMap;
		public ProcessorChange(String name) {
			super(name);
		}
		public void setParticipantMap(Map map) {
			fParticipantMap= map;
		}
		protected void internalHandleException(Change change, Throwable e) {
			RefactoringParticipant participant= (RefactoringParticipant)fParticipantMap.get(change);
			if (participant != null) {
				ParticipantDescriptor descriptor= participant.getDescriptor();
				descriptor.disable();