mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 14:12:10 +02:00
Bug 558474: Remove dead code
As part of trying to migrate SubProgressMonitor -> SubMonitor this code was identified as being unreachable. As this dead code had a lot of SubProgressMonitor it seems more suitable to just delete the dead code rather than migrate it to SubMonitor API. Change-Id: Idb9f96cb0d83ba0e7f617fab3bb6397e93824bba
This commit is contained in:
parent
ba208cbd06
commit
711cb3c4b9
1 changed files with 13 additions and 120 deletions
|
@ -17,18 +17,13 @@ package org.eclipse.cdt.internal.ui.refactoring;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.Assert;
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.jobs.IJobManager;
|
import org.eclipse.core.runtime.jobs.IJobManager;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
import org.eclipse.jface.operation.IRunnableContext;
|
||||||
import org.eclipse.ltk.core.refactoring.Change;
|
import org.eclipse.ltk.core.refactoring.Change;
|
||||||
|
@ -36,7 +31,6 @@ import org.eclipse.ltk.core.refactoring.PerformChangeOperation;
|
||||||
import org.eclipse.ltk.core.refactoring.Refactoring;
|
import org.eclipse.ltk.core.refactoring.Refactoring;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringCore;
|
import org.eclipse.ltk.core.refactoring.RefactoringCore;
|
||||||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||||
import org.eclipse.ltk.ui.refactoring.RefactoringUI;
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.swt.custom.BusyIndicator;
|
import org.eclipse.swt.custom.BusyIndicator;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
@ -51,67 +45,8 @@ public class RefactoringExecutionHelper {
|
||||||
private final Refactoring fRefactoring;
|
private final Refactoring fRefactoring;
|
||||||
private final Shell fParent;
|
private final Shell fParent;
|
||||||
private final IRunnableContext fExecContext;
|
private final IRunnableContext fExecContext;
|
||||||
private final int fStopSeverity;
|
|
||||||
private final int fSaveMode;
|
private final int fSaveMode;
|
||||||
|
|
||||||
private class Operation implements IWorkspaceRunnable {
|
|
||||||
Change fChange;
|
|
||||||
PerformChangeOperation fPerformChangeOperation;
|
|
||||||
final boolean fForked;
|
|
||||||
final boolean fForkChangeExecution;
|
|
||||||
final boolean fCancelable;
|
|
||||||
|
|
||||||
public Operation(boolean forked, boolean forkChangeExecution, boolean cancelable) {
|
|
||||||
fForked = forked;
|
|
||||||
fForkChangeExecution = forkChangeExecution;
|
|
||||||
this.fCancelable = cancelable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(IProgressMonitor pm) throws CoreException {
|
|
||||||
try {
|
|
||||||
pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$
|
|
||||||
pm.subTask(""); //$NON-NLS-1$
|
|
||||||
|
|
||||||
final RefactoringStatus status = fRefactoring.checkAllConditions(
|
|
||||||
new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
|
||||||
if (status.getSeverity() >= fStopSeverity) {
|
|
||||||
final boolean[] canceled = { false };
|
|
||||||
if (fForked) {
|
|
||||||
fParent.getDisplay().syncExec(() -> canceled[0] = showStatusDialog(status));
|
|
||||||
} else {
|
|
||||||
canceled[0] = showStatusDialog(status);
|
|
||||||
}
|
|
||||||
if (canceled[0]) {
|
|
||||||
throw new OperationCanceledException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fChange = fRefactoring
|
|
||||||
.createChange(new SubProgressMonitor(pm, 2, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
|
||||||
fChange.initializeValidationData(
|
|
||||||
new SubProgressMonitor(pm, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
|
||||||
|
|
||||||
fPerformChangeOperation = createPerformChangeOperation(fChange);
|
|
||||||
|
|
||||||
if (!fForked || fForkChangeExecution)
|
|
||||||
fPerformChangeOperation
|
|
||||||
.run(new SubProgressMonitor(pm, 4, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
|
||||||
} finally {
|
|
||||||
pm.done();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param status the status to show
|
|
||||||
* @return <code>true</code> iff the operation should be cancelled
|
|
||||||
*/
|
|
||||||
private boolean showStatusDialog(RefactoringStatus status) {
|
|
||||||
Dialog dialog = RefactoringUI.createRefactoringStatusDialog(status, fParent, fRefactoring.getName(), false);
|
|
||||||
return dialog.open() == IDialogConstants.CANCEL_ID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new refactoring execution helper.
|
* Creates a new refactoring execution helper.
|
||||||
*
|
*
|
||||||
|
@ -128,54 +63,24 @@ public class RefactoringExecutionHelper {
|
||||||
Assert.isNotNull(parent);
|
Assert.isNotNull(parent);
|
||||||
Assert.isNotNull(context);
|
Assert.isNotNull(context);
|
||||||
fRefactoring = refactoring;
|
fRefactoring = refactoring;
|
||||||
fStopSeverity = stopSeverity;
|
|
||||||
fParent = parent;
|
fParent = parent;
|
||||||
fExecContext = context;
|
fExecContext = context;
|
||||||
fSaveMode = saveMode;
|
fSaveMode = saveMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called in the UI thread.
|
|
||||||
* @param fork if set, the operation will be forked
|
|
||||||
* @param cancelable if set, the operation will be cancelable
|
|
||||||
* @throws InterruptedException thrown when the operation is canceled
|
|
||||||
* @throws InvocationTargetException thrown when the operation failed to execute
|
|
||||||
*/
|
|
||||||
public void perform(boolean fork, boolean cancelable) throws InterruptedException, InvocationTargetException {
|
|
||||||
perform(fork, false, cancelable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called in the UI thread.<br>
|
|
||||||
* <strong>Use {@link #perform(boolean, boolean)} unless you know exactly what you are doing!</strong>
|
|
||||||
*
|
|
||||||
* @param fork if set, the operation will be forked
|
|
||||||
* @param forkChangeExecution if the change should not be executed in the UI thread: This may not work in any case
|
|
||||||
* @param cancelable if set, the operation will be cancelable
|
|
||||||
* @throws InterruptedException thrown when the operation is canceled
|
|
||||||
* @throws InvocationTargetException thrown when the operation failed to execute
|
|
||||||
*/
|
|
||||||
public void perform(boolean fork, boolean forkChangeExecution, boolean cancelable)
|
|
||||||
throws InterruptedException, InvocationTargetException {
|
|
||||||
Operation operation = new Operation(fork, forkChangeExecution, cancelable);
|
|
||||||
performOperation(operation, null, fork);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performChange(Change change, boolean fork) throws InterruptedException, InvocationTargetException {
|
public void performChange(Change change, boolean fork) throws InterruptedException, InvocationTargetException {
|
||||||
PerformChangeOperation operation = createPerformChangeOperation(change);
|
PerformChangeOperation operation = createPerformChangeOperation(change);
|
||||||
performOperation(null, operation, fork);
|
performOperation(operation, fork);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes either a complete refactoring operation or a change operation.
|
* Executes either a complete refactoring operation or a change operation.
|
||||||
* @param operation The refactoring operation. Can be <code>null</code>.
|
* @param changeOperation The change operation. Has to be not <code>null</code>.
|
||||||
* @param changeOperation The change operation. Has to be <code>null</code> if {@code operation}
|
|
||||||
* is not <code>null</code> and not <code>null</code> otherwise.
|
|
||||||
* @param fork If set, the execution will be forked.
|
* @param fork If set, the execution will be forked.
|
||||||
*/
|
*/
|
||||||
private void performOperation(Operation operation, PerformChangeOperation changeOperation, boolean fork)
|
private void performOperation(PerformChangeOperation changeOperation, boolean fork)
|
||||||
throws InterruptedException, InvocationTargetException {
|
throws InterruptedException, InvocationTargetException {
|
||||||
Assert.isTrue((operation == null) != (changeOperation == null));
|
Assert.isTrue(changeOperation != null);
|
||||||
Assert.isTrue(Display.getCurrent() != null);
|
Assert.isTrue(Display.getCurrent() != null);
|
||||||
final IJobManager manager = Job.getJobManager();
|
final IJobManager manager = Job.getJobManager();
|
||||||
final ISchedulingRule rule = getSchedulingRule();
|
final ISchedulingRule rule = getSchedulingRule();
|
||||||
|
@ -188,19 +93,8 @@ public class RefactoringExecutionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(fSaveMode);
|
RefactoringSaveHelper saveHelper = new RefactoringSaveHelper(fSaveMode);
|
||||||
if (operation != null) {
|
|
||||||
if (!saveHelper.saveEditors(fParent))
|
|
||||||
throw new InterruptedException();
|
|
||||||
}
|
|
||||||
fRefactoring.setValidationContext(fParent);
|
fRefactoring.setValidationContext(fParent);
|
||||||
try {
|
try {
|
||||||
if (operation != null) {
|
|
||||||
fExecContext.run(fork, operation.fCancelable, new WorkbenchRunnableAdapter(operation, rule, true));
|
|
||||||
changeOperation = operation.fPerformChangeOperation;
|
|
||||||
fork = fork && !operation.fForkChangeExecution;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (changeOperation != null) {
|
|
||||||
if (fork)
|
if (fork)
|
||||||
fExecContext.run(false, false, new WorkbenchRunnableAdapter(changeOperation, rule, true));
|
fExecContext.run(false, false, new WorkbenchRunnableAdapter(changeOperation, rule, true));
|
||||||
RefactoringStatus validationStatus = changeOperation.getValidationStatus();
|
RefactoringStatus validationStatus = changeOperation.getValidationStatus();
|
||||||
|
@ -210,9 +104,8 @@ public class RefactoringExecutionHelper {
|
||||||
validationStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL)));
|
validationStatus.getMessageMatchingSeverity(RefactoringStatus.FATAL)));
|
||||||
throw new InterruptedException();
|
throw new InterruptedException();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
if (changeOperation != null && changeOperation.changeExecutionFailed()) {
|
if (changeOperation.changeExecutionFailed()) {
|
||||||
ChangeExceptionHandler handler = new ChangeExceptionHandler(fParent, fRefactoring);
|
ChangeExceptionHandler handler = new ChangeExceptionHandler(fParent, fRefactoring);
|
||||||
Throwable inner = e.getTargetException();
|
Throwable inner = e.getTargetException();
|
||||||
if (inner instanceof RuntimeException) {
|
if (inner instanceof RuntimeException) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue