RefactoringElementListener: How to get old name/package?

There sure must be a way for a refactor listener to access the old name of a renamed member?
I'd like to also move some associated company-specific resource data whenever some certain members are moved.

3 comments
Comment actions Permalink

Stephen Kelvin wrote:

There sure must be a way for a refactor listener to access the old name of a renamed member?
I'd like to also move some associated company-specific resource data whenever some certain members are moved.


When you create the listener for the PsiElement, you'll need to make the
listener remember with internal fields whatever original state you need
to be able to perform the rename (e.g. name). It appears that the
listener is only created at the time of renaming, so you don't need to
worry about the listener holding onto stale information. Also, you can't
just keep a reference to the element in the listener because the element
will change to its new state after the rename; you must keep copies of
the data from the element that you need to handle the rename.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0
Comment actions Permalink

Thanks so much, Gordon. These are my very first steps in Idea plug-in development and documentation is, hm, sub-optimal.
I was so focused on the listener class, I did not really think about making better use of the provider class.

0
Comment actions Permalink

Stephen Kelvin wrote:

and documentation is, hm, sub-optimal.

Working on that.

Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

Please sign in to leave a comment.