How to extend Eclipse's rename refactoring to trigger another refactoring after its completion
Asked Answered
N

2

7

I'm trying to extend eclipse's rename refactoring to call another rename refactoring.

public class Person {  
  ...  
}

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

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

I've extended RenameParticipant and tried to do it by using both JDT rename refactoring and ASTRewrite.

The problem is the changes I create conflict with the original rename refactoring changes.
I couldn't use postCreateChange (it seems the basic processor only returns null) and now I'm stuck.

Any help is much appreciated.

Natashianatassia answered 13/11, 2012 at 13:23 Comment(1)
What kind of conflict does your change have with the original rename refactoring changes?Blast
P
1

There is no possibility to change the String "Person" defined in methods by the new value "User" with refactoring.

But you can use Ctrl+H to search on the full workspace the needed String and replace it with the new Value.

enter image description here

When you click on Replace button, Eclipse will ask you the new value that will raplace the serched String.

Perfectionist answered 30/4, 2013 at 15:48 Comment(0)
B
1

Better suggestions:

1) Use Hibernate. You'll then be using the Criteria API, won't need to specify "Person" redundantly, and can attach other restrictions/criteria in a modular way -- good for List/ Search pages.

2) Call your API getByName(). List people = personDao.getPersonByName("...") is bit redundantly repeatedly repetitive, already.

The whole thing looks kinda like the 'wrong way' to do DAOs, database access, or persistence, which I've seen in previous projects. The combination of overly-wordy, yet inflexible & low-utility criteria, just reminds me of manually written persistence or services done badly in the mid-90s.

Bishopric answered 2/5, 2013 at 9:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.