views:

487

answers:

4

The obvious thing to do would be to:

  1. Right-click on the folder that you wish to format.
  2. Source > Format

Expected results:
- All java code in the directory and subdirectories are formatted (using the project specific formatting settings)

Actual results:
- None of the java is formatted.

While we're at it, how can we do a batch clean up operation in Eclipse?
From editor, I Right-click > Source > Clean Up, but I can only do one file at a time.

+1  A: 

As mentioned in this thread, this (format all jaava source files within a folder) should work since eclipse3.0.

Do you see some kind of error message in the "errors view" ?

VonC
I didn't get any error messages. I noticed that several XML files were touched.Maybe I did something wrong. I'll try again. Tried again:The problem is definitely that only XML files are formatted.
LES2
A: 

I did exactly as you suggested you would like to do, and it did exactly what you suggested was expected. I selected Source | Format for a directory in my src tree and it reformatted all the units within.

EDIT: ...with 3.4.1 Ganymede.

JMD
A: 

If your code isn't checked out from source control or isn't writable, doing a group operation like this won't check them out or make them writable.

Paul Tomblin
The files are all writable / checked out (using the Eclipse subversion integration [plus we have Tortoise for use in Explorer]).
LES2
In that case, I don't know why you didn't get the same results as @JMD, or as I did when I tried "Organize Imports" on a whole folder.
Paul Tomblin
+1  A: 

I faced the same issue. I had to switch to packaged Explorer to use the formatter. Under Navigator it does not work. Hope this help.