How to retrieve refactoring arguments

Hello,

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).

Thanks!

3 comments
Comment actions Permalink

Hi,
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.

0
Comment actions Permalink

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.

0
Comment actions Permalink

That's a bug, fixed. thanks!

0

Please sign in to leave a comment.