Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse cleanup code-style for entire package/class set

Tags:

java

eclipse

Is there any way to run the Eclipse cleanup rules on a whole set of classes/packages instead of individual classes?

(Preferences > Java > Code Style > Clean Up)

I right-click on the class and invoke Source-Clean Up, but it sure would be nice to invoke it on a set of classes.

like image 358
Kapsh Avatar asked Jun 05 '09 16:06

Kapsh


2 Answers

I'm not sure from your question if you're right clicking in the Editor or in one of the other views. However, if you select multiple multiple source files or folders in the Package Explorer you can right click in the Package Explorer and do Source -> Clean Up. The title in the first page of the Clean Up wizard should indicate how many files are going to be cleaned (e.g. "Cleaning up 20 files in 1 project")

like image 179
mikej Avatar answered Oct 16 '22 18:10

mikej


I suspect what you really want to do is apply a "code cleanup" to ALL of your java source files, not just ones that you selected manually.

Here's how:

1) In the Packages view (or the Package Explorer view) change your "Package Presentation" from "hierarchical" to "flat". There's a little upside down triangle in the top right corner of each view that lets you change this setting.

2) Now when you navigate to your source code directory you should see ALL the packages and sub packages and sub sub packages that contain your java source files, all presented together in one (possibly huge) list.

3) Of course, when you have a huge list like this, you can easily select all the packages (left-click the first one, then shift left-click the last one).

4) Then, right click on the selection, and go to "Source->Clean Up..." (or any other "Source" submenu item, like "Organize Imports") and the dialog that pops up will tell you how many source files it is about to change.

Hope that helps!

like image 22
Xanatos Avatar answered Oct 16 '22 20:10

Xanatos