Refactor rename undo not working [message #779703] |
Mon, 16 January 2012 11:06 |
Mikael Petterson Messages: 158 Registered: July 2009 |
Senior Member |
|
|
Hi,
When we do a refactor --> rename of a java file, Test.java . The following is happening:
- Rename compilation Unit is showed (refactor_rename_step1).
- The file is checked out. Test.java (changes_to_be_performed).
Then I cancel and an option to Undo is visible (cancel_move).
- I select "Undo" and the dialog is closed but the file is still checked out.
Q1:How can I make operation for checkout be part of the UndoManager?
I have not found any documentation around the connection between refactoring and the underlying version handling system.
I have added a stack trace for Creating changes ... (create_changes_stack_trace).
Q2:I don't see how it is possible to add Undo when the validateEdit is called?
br,
//mike
[Updated on: Mon, 16 January 2012 11:56] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
Re: Refactor rename undo not working [message #782848 is a reply to message #780721] |
Tue, 24 January 2012 15:15 |
Mikael Petterson Messages: 158 Registered: July 2009 |
Senior Member |
|
|
Hi,
I fixed checkout operation to adhere the IUndoable interface:
public void checkout(IResource[] resources, int depth,
IProgressMonitor progress) throws TeamException {
IUndoableOperation operation = new net.sourceforge.eclipseccase.CheckOutOperation(this,"checkout",resources, depth);
IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
IWorkbench wb = PlatformUI.getWorkbench();
IUndoContext undoContext = wb.getOperationSupport().getUndoContext();
operation.addContext(undoContext);
try {
operationHistory.execute(operation,progress,null);
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally {
setComment("");
}
}
The CheckOutOperation extends AbstractOperation as in:
http://help.eclipse.org/indigo/topic/org.eclipse.platform.doc.isv/guide/wrkAdv_undo.htm?resultof=%22%55%6e%64%6f%22%20%22%75%6e%64%6f%22%20
And when debugging the plugin I can see that ( stubb ) no call to undo in CheckOutOperation when I "cancel" and "undo" refactoring (rename).
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
MessageDialog.openInformation(PlatformUI.getWorkbench().
getActiveWorkbenchWindow().getShell(),
"Checkout",
"Undoing view action");
return Status.OK_STATUS;
}
What is missing? Does the undoContext need to be different?
br,
//mike
|
|
|
Re: Refactor rename undo not working [message #783344 is a reply to message #779703] |
Wed, 25 January 2012 15:00 |
Mikael Petterson Messages: 158 Registered: July 2009 |
Senior Member |
|
|
Hi,
I did debug with clearcase plugin installed:
public Change perform(IProgressMonitor pm) throws CoreException {
fUndoUntilException= null;
List undos= new ArrayList(fChanges.size());
pm.beginTask("", fChanges.size()); //$NON-NLS-1$
pm.setTaskName(RefactoringCoreMessages.CompositeChange_performingChangesTask_name);
Change change= null;
boolean canceled= false;
try {
for (Iterator iter= fChanges.iterator(); iter.hasNext();) {
change= (Change)iter.next();
if (canceled && !internalProcessOnCancel(change))
continue;
if (change.isEnabled()) {
Change undoChange= null;
try {
undoChange= change.perform(new SubProgressMonitor(pm, 1));
} catch(OperationCanceledException e) {
canceled= true;
if (!internalContinueOnCancel())
throw e;
undos= null;
}
if (undos != null) {
if (undoChange == null) {
undos= null;
} else {
undos.add(undoChange);
}
}
}
// remove the change from the list of children to give
// the garbage collector the change to collect the change. This
// ensures that the memory consumption doesn't go up when
// producing the undo change tree.
iter.remove();
// Make sure we dispose the change since it will now longer be
// in the list of children when call CompositeChange#dispose()
final Change changeToDispose= change;
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
changeToDispose.dispose();
}
public void handleException(Throwable exception) {
RefactoringCorePlugin.log(exception);
}
});
}
if (canceled)
throw new OperationCanceledException();
if (undos != null) {
Collections.reverse(undos);
return createUndoChange((Change[]) undos.toArray(new Change[undos.size()]));
} else {
return null;
}
} catch (CoreException e) {
handleUndos(change, undos);
internalHandleException(change, e);
throw e;
} catch (RuntimeException e) {
handleUndos(change, undos);
internalHandleException(change, e);
throw e;
}
}
In the above code the can see that the following is executed:
undoChange= change.perform(new SubProgressMonitor(pm, 1));
The following block is never reached.
if (undos != null) {
if (undoChange == null) {
undos= null;
} else {
undos.add(undoChange);
}
}
I was expecting this to happen.
undos.add(undoChange);
But it does not. Is that correct behaviour?
br,
//mike
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06923 seconds