Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 311707 - [ltk] CopyDescriptor doesn't have enough arguments to handle copying
Summary: [ltk] CopyDescriptor doesn't have enough arguments to handle copying
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-05 08:08 EDT by Yuri Strot CLA
Modified: 2020-02-11 12:21 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri Strot CLA 2010-05-05 08:08:46 EDT
Hi,

I'm working on the Annotation Framework in the Tigerstripe project and I need to handle java elements changes. I've already added this support for renaming, moving and deleting but have a problem with copying.

If I copy class to the same package I can enter new name for copied class. For example I can copy TestClass to TestClass2. I'm using IRefactoringExecutionListener and getting CopyDescriptor from the refactoring event. But this descriptor contains only following arguments:
{files=0, folders=0, policy=org.eclipse.jdt.ui.copyResources, element1=/src<pack{TestClass.java, units=1, version=1.0, destination=/src<pack}

So there are no information about new class name. Is there any way to take it?
Comment 1 Olivier Thomann CLA 2010-05-05 09:51:33 EDT
Move to JDT/UI
Comment 2 Markus Keller CLA 2010-05-10 05:48:07 EDT
Reproduced. The problem is that ReorgPolicyFactory$CopyFilesFoldersAndCusPolicy.createRefactoringDescriptor(JDTRefactoringDescriptorComment, Map, String, String, int) line: 295	
calls storeReorgExecutionLog(..) at a time when the new names are not yet known (they are only queried in CreateCopyOfCompilationUnitChange#getOldFile(IProgressMonitor)). 

I think they only way you can get at this information is by contributing a CopyParticipant: Override getChange(..) and return a dummy change whose perform(..) method does something like this:
public Change perform(IProgressMonitor pm) throws CoreException {
	CopyArguments arguments = getArguments();
	ReorgExecutionLog executionLog = arguments.getExecutionLog();
	Object[] processedElements = executionLog.getProcessedElements();
	for (int i = 0; i < processedElements.length; i++) {
		String newName= executionLog.getNewName(processedElements[i]);
		// store newName
	}
	return super.perform(pm);
}


Hint: To hide your change in the preview, wrap it into a CompositeChange and call markAsSynthetic() on it.
Comment 3 Yuri Strot CLA 2010-05-11 09:07:57 EDT
Hi Markus,

Thank you very much! This workaround works for me.
Comment 4 Eclipse Genie CLA 2020-02-11 12:21:47 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.