Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Refactor rename undo not working
Refactor rename undo not working [message #779703] Mon, 16 January 2012 11:06 Go to next message
Mikael Petterson is currently offline Mikael PettersonFriend
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 #780131 is a reply to message #779703] Tue, 17 January 2012 08:36 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 1/16/2012 4:36 PM, Mikael Petterson wrote:
> - The file is checked out. Test.java (changes_to_be_performed).
What do you mean by 'file is checked out'?

Do you mean the file is checked out from a source control system e.g.
CVS, Git when you perform Rename refactoring? That sounds a bit strange
to me...

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #780337 is a reply to message #779703] Tue, 17 January 2012 16:12 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
Your question from the mailing list

"Q1: Must the vcs operation, (clearcase plugin) adhere to the
IUndoableOperation to be undone when "Undo" is pressed?"

Any reason why you think it is an issue with JDT and not with the
'Clearcase plugin?

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #780469 is a reply to message #780337] Wed, 18 January 2012 07:46 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
Messages: 158
Registered: July 2009
Senior Member
Hi,

Thanks for reply.

I try to answer your questions here:

Do you mean the file is checked out from a source control system e.g.
CVS, Git when you perform Rename refactoring? That sounds a bit strange
to me...


yes it is checked out from clearcase when doing the Refactor --> Rename. And this is before preview of what will be changed. I don't see reason for checkout before the actual move is done.

Any reason why you think it is an issue with JDT and not with the
'Clearcase plugin?


That is what I am trying to sort out. Just to be clear that the clearcase plugin adhere to the IUndoableOperation to be undone when "Undo" is pressed? Is that so?
This would make it easier to point out where the problem is.

Let me know if you need more information.

br,

//mike
Re: Refactor rename undo not working [message #780503 is a reply to message #780469] Wed, 18 January 2012 10:50 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 1/18/2012 1:16 PM, Mikael Petterson wrote:
> yes it is checked out from clearcase when doing the Refactor --> Rename.
> And this is before preview of what will be changed. I don't see reason
> for checkout before the actual move is done.

JDT expects the file to be in the workspace and has no knowledge of the
version control system you are using. The problem should be with the
Clearcase plugin.

> That is what I am trying to sort out. Just to be clear that the
> clearcase plugin adhere to the IUndoableOperation to be undone when
> "Undo" is pressed? Is that so?
Yes.

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #780517 is a reply to message #780503] Wed, 18 January 2012 12:31 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
Messages: 158
Registered: July 2009
Senior Member
create_changes_stack_trace

JDT expects the file to be in the workspace and has no knowledge of the
version control system you are using. The problem should be with the
Clearcase plugin.

The attached picture,create_changes_stack_trace, shows that a call is made to validateEdit() from This is not initiated by clearcase plugin. See stacktrace picture.
A repository plugin must implement the validateEdit() - method but it is not called from clearcase plugin.

br,

//mike
Re: Refactor rename undo not working [message #780683 is a reply to message #780517] Thu, 19 January 2012 02:40 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 1/18/2012 6:01 PM, Mikael Petterson wrote:
> The attached picture,create_changes_stack_trace, shows that a call is
> made to validateEdit() from This is not initiated by clearcase plugin.
> See stacktrace picture.
> A repository plugin must implement the validateEdit() - method but it is
> not called from clearcase plugin.

Of course, the Clearcase plugin participates in the refactoring via some
extension mechanism but that does not make JDT responsible for what it does.

Please take it up with Clearcase plugin providers.

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #780699 is a reply to message #780683] Thu, 19 January 2012 06:13 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
Messages: 158
Registered: July 2009
Senior Member
Hi,

What mechanism do you refer to? The only mechanism that I can see in the clearcase plugin code is is that org.eclipse.core.resources.IFileModificationValidator.validateEdit() is used.
What shall be used instead for a refactoring --> rename? It is called from RenameRefactoring ( according to stack trace). So what is missing in implementation?

br,

//mike
Re: Refactor rename undo not working [message #780721 is a reply to message #780699] Thu, 19 January 2012 08:06 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
Clearcase plugin checks out the file.
=> Clearcase plugin needs to undo that operation.

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #782848 is a reply to message #780721] Tue, 24 January 2012 15:15 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
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 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
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
Re: Refactor rename undo not working [message #786486 is a reply to message #782848] Mon, 30 January 2012 13:43 Go to previous messageGo to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
> What is missing? Does the undoContext need to be different?
Could be. I will have to debug this code to be sure (but I do not have
Clearcase plugin code, so I can't help there)

Undo - global undo history and undo contexts - can be tricky. For
example see https://bugs.eclipse.org/bugs/show_bug.cgi?id=345342.

Please take it up with Clearcase plugin provider and they can nail down
the exact problem and open a bug against JDT (with more info) if needed.
From my side, I will keep an eye out for any potential issues in this
area while working on the above mentioned bug.

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Re: Refactor rename undo not working [message #788131 is a reply to message #786486] Wed, 01 February 2012 11:36 Go to previous messageGo to next message
Mikael Petterson is currently offline Mikael PettersonFriend
Messages: 158
Registered: July 2009
Senior Member
Hi again,

The source code as well as link to update site for the plugin is here:

http://sourceforge.net/projects/eclipse-ccase/

I am part of plugin provider team Smile

In previous mail I already pointed out that the:

if (undos != null) {
  if (undoChange == null) {
	undos= null;
  } else {
	undos.add(undoChange);
  }
}


was never reached.
What more would you like from us? Please let me know.

br,

//mike
Re: Refactor rename undo not working [message #788158 is a reply to message #788131] Wed, 01 February 2012 12:14 Go to previous message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 543
Registered: July 2009
Senior Member
On 2/1/2012 5:06 PM, Mikael Petterson wrote:
> Hi again,
>
> The source code as well as link to update site for the plugin is here:
>
> http://sourceforge.net/projects/eclipse-ccase/
>
> I am part of plugin provider team :)

Sorry, I did not realize that :-)

> In previous mail I already pointed out that the:
>
> if (undos != null) {
> if (undoChange == null) {
> undos= null;
> } else {
> undos.add(undoChange);
> }
> }

Which type and which method are you referring to here ?

--
Deepak Azad
http://wiki.eclipse.org/JDT/FAQ
Previous Topic:Problem Referencing Nested Inner Classes
Next Topic:eclipse looses linked sources
Goto Forum:
  


Current Time: Fri Apr 26 07:07:59 GMT 2024

Powered by FUDForum. Page generated in 0.04594 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top