How to extend Eclipse rename refactoring to start another refactoring after it is completed

I am trying to extend the eclipse rename refactoring to trigger another rename refactoring.

public class Person { ... } public class PersonDAO { public List<Person> getPersonByName(String name) { ... } } 

After renaming the Person class to User, I want methods such as getPersonByName to be renamed to getUserByName .

I extended RenameParticipant and tried to do this using refactoring renaming JDT and ASTRewrite.

The problem is the changes that I create in conflict with the initial renaming refactoring changes.
I could not use postCreateChange (it seems that the main processor returns null), and now I'm stuck.

Any help is greatly appreciated.

+7
source share
2 answers

There is no way to change the string "Man" defined in the methods with the new value "User" with refactoring.

But you can use Ctrl + H to search the entire workspace for the desired line and replace it with a new value.

enter image description here

When you click the Replace button, Eclipse will ask you for a new value that will replace the core string.

+1
source

Best offers:

1) Use Hibernate. Then you will use the criteria API, you will not need to specify the "Personality" excessively and can join other restrictions / criteria in a modular way - useful for list / search pages.

2) Call the getByName () API. The list people = personDao.getPersonByName ("...") is already redundantly repeated.

It all looks like the β€œwrong way” to do DAO, database access or persistence, as I saw in previous projects. The combination of too verbose, but inflexible and of little use criteria simply reminds me of hand-written perseverance or services done poorly in the mid-90s.

+1
source

All Articles