简体   繁体   中英

Changing Eclipse's refactor tool behavior

I'm in the process of refactoring a large amount of code. Eclipse's refactor tool is extremely handy for this, but I'm running into a bit of a snag.

For example, the original file has these imports:

import com.a.TestClass;
import com.b.TestClass;
import com.b.BClass;

In refactoring, I move and rename com.b.BClass to com.a.AClass so Eclipse will insert AClass into alphabetic order on the import list:

import com.a.AClass;
import com.a.TestClass;
import com.b.TestClass;

This is normally a nice feature, but in my case it's a bit of a hassle since it's harder to figure out how to merge correctly. Is there any way to change this behavior?

You have two options:

  1. Organise imports on all the files before you start. Probably the more workable solution

  2. Work out the current order of the classes in the import and configure eclipse's organise imports to order the same way.

I would strongly recommend option 1 - don't think option 2 will work.

Unless there's a specific reason you can't, I'd say just commit more often. Move/rename a class? Run the tests, commit. If you do it in baby-steps then there's no merge hassle. (well, less of it anyway).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM