Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » PushDownDescriptor bug?
PushDownDescriptor bug? [message #259535] Mon, 13 April 2009 12:17
Eclipse UserFriend
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
Previous Topic:Breakpoint changes behavior of program?!
Next Topic:Getting ITypeBinding from a fully qualified class name. Is it possible?
Goto Forum:
  


Current Time: Sun Apr 20 10:19:08 EDT 2025

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

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

Back to the top