Community
Participate
Working Groups
The code formatter (using Java style default formatter) doesn't format a block with a return statement properly. For example: void doX() { if (1 > 0) { return; } return; } It will format it as: void doX() { if (1 > 0) { return; } return; }
What build are you using?
Using java conventions settings, I get: public class A { void doX() { if (1 > 0) { return; } return; } } Could you please provide build id + your code formatter preferences (export them into a file that you attach to this PR)? Thanks
It looks like this may have been fixed in 3.0M8 (which I'm using now). However, the following addition does cause the error: if (1 > 0) { // return; } gets formatted the way I reported
In order to get a different formatting, it means that a block with only a return statement and a line comment is not considered as a guard clause. Then you would get something like this: if (1 > 0) { // return; } after formatting. Is this what you expect?
With the change described in comment 4, I get: public class A { void doX() { if (1 > 0) {// return; } return; } }
I still get the issue I reported: if (1 > 0) { // return; } becomes if (1 > 0) { // return; } Not sure why we're seeing differences.
Fixed and released in HEAD. Regression test added. The fix is not to format { // return;} as a guard clause, because of the line comment. In your last test case, you would end up with: if (1 > 0) { // return; }
Verified for 3.0M9
Reproduced today on Eclipse IDE for JavaScript Web Developers. Version: Indigo Release Build id: 20110615-0604 Pc W7x64 home premium [Return] in a [If] block does not format correctly AND cause the formatter to stop working completely (ctrl+shift+f has no effect afterward). Adding a comment tag like this : if(i>0){ // return i; } acts as a workaround and re-enable the formatter.