PushDownDescriptor bug? [message #259535] |
Mon, 13 April 2009 16:17 |
Ioana Verebi Messages: 6 Registered: July 2009 |
Junior Member |
|
|
Hello,
I am experimenting with the Java refactorings provided by the JDT. I am
trying to push down a method and leave the abstract declaration of the
method in the refactored class. I created the refactoring descriptor and
argument map. The argument map contains:
private static final String ATTRIBUTE_ABSTRACT= "abstract";
public static final String ATTRIBUTE_ELEMENT= "element";
String methodHandle = ... // get the input handle for the method
arguments.put(ATTRIBUTE_ELEMENT + 1, methodHandle);
arguments.put(ATTRIBUTE_ABSTRACT + 1,
Boolean.valueOf(true).toString());
The only problem is that whatever I do, the method is pushed down and in
the refactored class there is no abstract declaration of the method.
I've inspected the problem further and found that when the initial
conditions are checked(via
org.eclipse.jdt.internal.corext.refactoring.structure.PushDo wnRefactoringProcessor.checkInitialConditions(IProgressMonit or)),
the map is reset to push down the method.
The only way I could make it to work was to
1.check the initial conditions
2.configure the CheckConditionsOperation to check only the final
conditions
3.reset the action for the method
4.run the refactoring.
pushDown.checkInitialConditions(new
NullProgressMonitor());
[....]
CreateChangeOperation create = new CreateChangeOperation(new
CheckConditionsOperation(pushDown,
CheckConditionsOperation.FINAL_CONDITIONS), RefactoringStatus.FATAL);
PerformChangeOperation perform = new PerformChangeOperation(create);
PushDownRefactoringProcessor pushDownRefactoringProcessor =
(PushDownRefactoringProcessor) pbr.getProcessor();
MemberActionInfo[] memberActionInfos =
pushDownRefactoringProcessor.getMemberActionInfos();
for (int i = 0; i < memberActionInfos.length; i++) {
if (memberActionInfos[i].getMember().equals(theMethod))
memberActionInfos[i].setAction(PushDownRefactoringProcessor. PUSH_ABSTRACT_ACTION);
}
[....]
ResourcesPlugin.getWorkspace().run(perform, new
NullProgressMonitor());
The problem is that this is a hack that uses internal classes. Is there
another way to achieve the same result using non-internal code? Am I
missing something or is this a bug?
Thanks,
Ioana
|
|
|
Powered by
FUDForum. Page generated in 0.02470 seconds