How to retrieve refactoring arguments


When listening to refactorings, is there a way to retrieve the refactoring arguments with which the refactoring was called? (e.g. for a Rename Method refactoring an argument would be the new name, for an Extract Superclass refactoring some arguments would be: superclass name, list of methods to pull up). Bassically all the arguments needed to replay the refactoring later on.

I currently listen to refactorings with a RefactoringEventListener whose events give me a RefactoringEventData. From what I figured out, the RefactoringEventData only gives me information about which PSI elements the refactoring was performed on and nothing about the other arguments.

In Eclipse this is achieved with RefactoringContribution.retrieveArgumentMap(RefactoringDescriptor).



the listener is correct. You are provided with before/after data, so you may retrieve everything you need, e.g. new name is the name of the element after refactoring.


I've just tested it out and it's true for renames. On the other hand, it is still incomplete. For extract superclass it does not put the superclass name anywhere (neither in the refactoring started nor in the refactoring done event).

I was mainly looking for a mechanism that saves the context of each refactoring so that it can be replayed later on. Like a memento that you just load into the refactoring and then you can redo it without any user input.


That's a bug, fixed. thanks!


Please sign in to leave a comment.