Bug 86438 - [move method][refactoring] moveParticipants doesn't work for MoveInstanceMethod
Summary: [move method][refactoring] moveParticipants doesn't work for MoveInstanceMethod
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P5 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-24 02:18 EST by Danny Dig CLA
Modified: 2010-06-18 12:03 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Danny Dig CLA 2005-02-24 02:18:08 EST
Build id: I20050219-1500

I declared a move participant that should be notified when a MoveMethod  
refactoring performs. This works fine if I move a static method. I looked into 
the code and saw that MoveInstanceMethodRefactoring is also implemented using 
the processor/participant architecture. However, if I perform a 
MoveInstanceMethod my participant never gets called. 

Below is plugin.xml part that deals with this:

<extension point="org.eclipse.ltk.core.refactoring.moveParticipants">
 <moveParticipant  
class="edu.uiuc.refactoringparticipants.PersistenceMoveInstanceMethodParticipan
t" name="PersistenceMoveInstanceMethodParticipant" 
id="edu.uiuc.refactoringparticipants.PersistenceMoveInstanceMethodParticipant">
 <enablement>
     <with variable="affectedNatures">
      <iterate operator="or">
       <equals value="org.eclipse.jdt.core.javanature" /> 
     </iterate>
  </with>
  <with variable="element">
     <instanceof value="org.eclipse.jdt.core.IMethod" /> 
  </with>
  </enablement>
  </moveParticipant>
  </extension>


And the participant code is below:

public class PersistenceMoveInstanceMethodParticipant extends MoveParticipant {

	IMember member;
	protected boolean initialize(Object element) {
		member= (IMember) element;
		return true;
	}

	public String getName() {
		
		return "PersistenceMoveMemberParticipant";
	}

	public RefactoringStatus checkConditions(IProgressMonitor pm,
			CheckConditionsContext context) throws 
OperationCanceledException {
		return new RefactoringStatus();
	}

	public Change createChange(IProgressMonitor pm) throws CoreException,
			OperationCanceledException {
		System.out.println("AHA - got you!!!");
		return null;
	}
}


I tried to supply more information in the plugin.xml, at the moveParticipant 
extension point:

<with variable="processorId">
  <equals value="org.eclipse.jdt.ui.moveInstanceMethodProcessor" /> 
</with>

I got this from the MoveInstanceMethodProcessor's IDENTIFIER. Did not work 
either (my participant code never got called).

I also tried:
<with variable="processorId">
  <instanceOf value=  ... fully qualified name of 
MoveInstanceMethodProcessor /> 
</with>

and did not work either.

I inserted a breakPoint into ProcessorBasedRefactoring #createChange (the 
place where it iterates over all the participants and creates all their 
chages) and I noticed that fParticipants does not contain my participant at 
all.
Comment 1 Dirk Baeumer CLA 2005-02-24 06:02:29 EST
Dani,

although the refactoring is implemented as a processor it doesn't currently load
any participants(see method loadParticipants in MoveInstanceMethodProcessor).
The refactorings that support participants are listed in the interface
IRefactoringProcessorIds, which is public API.

Adding this support will very likely not happen for 3.1. Our current focus is
J2SE 5.0 and performance. 
Comment 2 Denis Roy CLA 2009-08-30 02:18:59 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 3 Vera Henneberger CLA 2010-06-17 15:20:20 EDT
I am developing the moreUnit plugin which helps user to write unit tests.
There is refacotring support: if a user renames a method, the testcase gets renamed as well...
I can not implement move method refactoring support for instance methods if participants are not supported.
Any chance this will be added?
Comment 4 Markus Keller CLA 2010-06-18 12:02:38 EDT
We have no plans to work on this, but we could look into a high quality patch. 

But note that this will not be as easy as participant support for moving resources or static members. The Move Instance Method refactoring not only moves the method, but it also adds a parameter sometimes, so this also needs to be reflected in the refactoring arguments.