Community
Participate
Working Groups
hi First let me thank you for all the great work on the Eclipse code formatter. It is a really great tool. But it lacks some important possibilities. I use to format return- and throw-statements like this: public MyClass getMyObject() { MyClass o = new MyClass(); doSomehting( 1 ); if (somethingBad) throw( new IllegalBlaException( "bad bla" ) ); return( o ); } If I ran my formatter over this code, it would produce the following: public MyClass getMyObject() { MyClass o = new MyClass(); doSomething( 1 ); if (somethingBad) throw (new IllegalBlaException( "bad bla" )); return(o); } See the missing spaces between the opening brance and the closing brace of the throw- and return-statement and the mistakenly added space after the throw statement. The code formatter doesn't support this formatting. I know, that not too many people do it like that, but I find it just logic. I guess (or hope) it is not a too big task to improve the formatter to also support this formatting. Could you maybe do that? It would also be cool, if one could configure the formatter to add these braces, if they're missing. Marvin
*** Bug 164947 has been marked as a duplicate of this bug. ***
(In reply to comment #0) > See the missing spaces between the opening brance and the closing brace of the > throw- and return-statement and the mistakenly added space after the throw > statement. Note that the space is mandatory if the expression is not a parenthesized expression. > The code formatter doesn't support this formatting. I know, that not too many > people do it like that, but I find it just logic. I guess (or hope) it is not a > too big task to improve the formatter to also support this formatting. Could > you maybe do that? It would also be cool, if one could configure the formatter > to add these braces, if they're missing. The code formatter doesn't add any characters. It simply formats whitespaces.
> See the missing spaces between the opening brace and the closing brace of the > throw- and return-statement and the mistakenly added space after the throw > statement. You need to set that you want a space after the opening parenthesize and before the closing one in a parenthesized expression. Go to the java formatter prefererence page and make your changes. The only option that is missing the optional space (in case of parenthesized expression) for the throw statement. The return statement has its corresponding option already. I'll add this one for throw statement as well, otherwise this is inconsistent. Will be done only in the 3.3 stream, since this requires API addition and this is prohibited for maintenance releases.
Released for 3.3M4. Need fix from bug 165050 to be visible in the UI.
>You need to set that you want a space after the opening parenthesize and before >the closing one in a parenthesized expression. >Go to the java formatter prefererence page and make your changes. Well, it's not exactly, what I want. This would format (1 + 2) to ( 1 + 2 ) , which I don't like. Would be great to see two additional options in White Space->Control Statements->'return' which can be found in many other settings in this group. "after opening parenthesis" and "before closing parenthesis". >The only option that is missing the optional space (in case of parenthesized >expression) for the throw statement. The return statement has its corresponding >option already. >I'll add this one for throw statement as well, otherwise this is inconsistent. >Will be done only in the 3.3 stream, since this requires API addition and this >is prohibited for maintenance releases. >Released for 3.3M4. >Need fix from bug 165050 to be visible in the UI. Thank you very much espeacially for the quick reply and fix. I don't like beta- or pre-versions. When will the final 3.3 be released? Marvin
(In reply to comment #6) > >You need to set that you want a space after the opening parenthesize and before the closing one in a parenthesized expression. > >Go to the java formatter prefererence page and make your changes. > > Well, it's not exactly, what I want. This would format > (1 + 2) > to > ( 1 + 2 ) > , which I don't like. Would be great to see two additional options in > White Space->Control Statements->'return' > which can be found in many other settings in this group. > "after opening parenthesis" and "before closing parenthesis". This lacks of consistency. In return (1), (1) is a parenthesized expression the same way that (1 + 2) is a parenthesized expression. If we add a new option for each usage of parenthesized expression, we will end up with too many options. So I am not too tempted to add more options. I added this one, because it was inconsistent with the handling of the return statement. > I don't like beta- or pre-versions. When will the final 3.3 be released? late June 2007. See http://www.eclipse.org/eclipse/development/eclipse_project_plan_3_3.html#Milestones
I added this one, because it was inconsistent with the handling of the return statement. Thanks. It indeed was. > I don't like beta- or pre-versions. When will the final 3.3 be released? late June 2007. Oh, that's a little late. Maybe I'll get a 3.3 milestone before. Is the return space fix also included in M4? Marvin
Verified for 3.3M4 with I20061212-0010.