Community
Participate
Working Groups
Although it seems not to be an official 'style', some people write: return(expression); rather than return expression; At the moment there is no control over the 'return' format, but automatically a space is retained after the keyword. As such is implemented for 'methods' there should be an entry that controls 'return' in the same way with respect to white space anywhere. ;JOOP!
The space is optional only if the following expression is a parenthesized expression or a cast expression. Do you see another case that should be supported?
(In reply to comment #1) > The space is optional only if the following expression is a parenthesized > expression or a cast expression. > Do you see another case that should be supported? If the space is optional, then why does the formatter add it in any case? methodCall(n); // Can be parameterised to remain as this. return(version); // No way to prevent insertion of a space. Ctrl/F : methodCall(n); // Can be parameterised to remain as this. return (version); // No way to prevent insertion of a space. ;JOOP!
I didn't say it was already optional. I am simply saying that if we make it optional, this option would work only for cast and parameterized expressions. For other types of expression, the space is mandatory.
(In reply to comment #3) > I didn't say it was already optional. > I am simply saying that if we make it optional, this option would work only for > cast and parameterized expressions. For other types of expression, the space is > mandatory. Well, if it would solve the sample I gave, I should be satisfied. ;JOOP!
Fixed and released in HEAD. Regression case added in org.eclipse.jdt.core.tests.formatter.FormatterRegressionTests.test606. This needs to be added in the code formatter preference page. See bug 111139.
I will rename the option FORMATTER_INSERT_SPACE_BEFORE_PARENTESIZED_EXPRESSION_IN_RETURN. Fixed and released. Adapted regression tests. Nothing is done for cast expression, prefix expressions or string literals.
Verified for 3.2 M3 using build I20051025-0800+v_619.