Skip to main content


Eclipse Community Forums
Forum Search:

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


Current Time: Thu Dec 26 14:40:03 GMT 2024

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

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

Back to the top