Type migration of a single field

I have multiple String fields, and i would like to migrate on of them to different type.

Is there any way to do it? Type migration function seems to migrate all String fields...

3 comments
Comment actions Permalink

Hello.

I've checked the dummy code like:

public class Source {
    private String field1;
    private String field2;
}

Called Refactor / Type Migration for the String type of field2: it changes only the type of field2, not field1.

Are your fields related via some expressions? Type Migration tries to change the types of all values involved into expressions to keep the code valid as possible.

Regards,
Alexander.

0
Comment actions Permalink

you are right, it works, but on my project, it just migrate like everything everywhere...
and i found why, there is one method which causes it all.

 private StringBuilder append(String s) {
 if (s == null) {
 return stringBuilder;
 }
 return stringBuilder.append(s);
}


because of that, it migrates one field which is used as ID everywhere, and because of that it migrates whole project... more than 200 migration conflicts instead of 2. This is OK then.


I can see that Migrate preview shows the problem when I go through the tree, but migration conflicts panel is somehow lazyly initialized, so it does not show them until I expand the nodes up there... this seems wrong, I would like to know that there is not 2 conflicts, but 200 right away.  
0
Comment actions Permalink

I have exactly the same problem. Wanted to migrate String employeeID; to Optional<String> employeeId; - so it's changed correctly into current file except the filed itself and lots of wrong places in the whole project. Extremely disappointed. 

0

Please sign in to leave a comment.