Bug 110304 - Formatter has no options for 'return'
Summary: Formatter has no options for 'return'
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 111139
  Show dependency tree
 
Reported: 2005-09-22 08:12 EDT by J.F.Lanting CLA
Modified: 2005-10-31 04:11 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description J.F.Lanting CLA 2005-09-22 08:12:49 EDT
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!
Comment 1 Olivier Thomann CLA 2005-09-24 10:54:26 EDT
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?
Comment 2 J.F.Lanting CLA 2005-09-24 11:58:14 EDT
(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!
Comment 3 Olivier Thomann CLA 2005-09-25 10:20:24 EDT
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.
Comment 4 J.F.Lanting CLA 2005-09-25 12:20:00 EDT
(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!
Comment 5 Olivier Thomann CLA 2005-09-29 16:43:11 EDT
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.
Comment 6 Olivier Thomann CLA 2005-10-05 13:37:13 EDT
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.
Comment 7 Frederic Fusier CLA 2005-10-31 04:11:52 EST
Verified for 3.2 M3 using build I20051025-0800+v_619.