Community
Participate
Working Groups
Although the new code formatter is good, there is one annoyance that I have spotted that I can't see logged elsewhere. I like to format my lines to have spaces in-between brackets (see code below), and it would seem that the formatter preferences allow this configuration. // Desired results System.out.println( title + " world" ); //$NON-NLS-1$ System.out.println( test.toString() ); However, if I format these statements, the space before the closing bracket is removed, leaving: // Wrong results - space removed before ');' construct System.out.println( title + " world"); //$NON-NLS-1$ System.out.println( test.toString()); This formatting behaviour happens consistently on method calls, but not constructor calls - which format properly. I have played with various options to see if this is a case where one option is overriding another, but can't resolve it. Ian
This occurs on Eclipse 3, build M6 - and also on the Integration builds between M5 and M6 in which the new formatting preferences featured.
Created attachment 7287 [details] Saved settings for Java code formatter This is the saved settings file used to create the reported problem
Another perspective on this issue (spacing in-between braces on method calls), the following code: Runtime.getRuntime().loadLibrary( filename ); System.loadLibrary( filename ); gets incorrectly formatted as: Runtime.getRuntime( ).loadLibrary( filename ); System.loadLibrary( filename); What is odd here (and the reason I have included it in the same report) is that: a) on the Runtime line, it has inserted a space in the getRuntime() call (wrong, in my opinion), but not removed the space after filename (correct, with this configuration) - BUT b) on the System line, it has incorrectly removed the space after filename (consistent with the original bug report). So it would seem that the method brace spacing behaviour is not consistent. I would like to vote that empty-brace method calls - eg getRuntime() - have no spaces, not 1 or 2. I mention this only because I don't want the fix for the removed space in the non-empty-brace method calls to mean that empty-brace method calls suddenly get 2 spaces!
I am investigating.
This is fixed. I added a new option to distinguish between empty arguments in method declarations vs empty argument in method invocations. Fixed and released in HEAD. Regression test added.
This is still fixed, but I am reusing the old option in method invocations as well. The new option is ready, but won't be released till Martin is back. So I will properly close it once the new option is used.
For your info, I have downloaded the latest nightly build (20040107). The basic condition is fixed, but one issue appears to still be there... Going back to a comment I added previously, the following code: Runtime.getRuntime().loadLibrary( filename ); System.loadLibrary( filename ); now gets formatted as: Runtime.getRuntime( ).loadLibrary( filename ); System.loadLibrary( filename ); So the method-call closing brackets on the loadLibrary calls are both now correctly formatted, but the space in the "getRuntime( )" brackets was unexpected. Not sure if this is: - Eclipse behaving itself - in which case I will create a new report to request the ability to configure that no-parameter method calls get no spaces in the brackets - giving "getRuntime()" OR - Expected behaviour based on one of the comments about the applied fix using an old option OR - An outstanding issue within the fix
Hopefully the fix will be completed today. You must have the option to add a white space between empty method arguments sets to true. I had to remove the new setting since one committer was not back from vacations yet. Don't worry once fixed, you should be able to configure if you want the whitespace between empty method arguments in a method invocation. Check your settings in: White Space>Declarations>Member Functions>between empty parenthesis. This option should be set. Uncheck it and it should work the way you want. A new option will be added soon to distinguish empty arguments in method declarations vs method invocations.
*** Bug 49634 has been marked as a duplicate of this bug. ***
Fixed and released in HEAD. Silvio, please add the new option FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_MESSAGESEND_ARGUMENTS in the code formatter preference page. By default this is false. Your last test case has been added as a regression test. I had a bug. I missed one case. Thanks for the report and the feedback.
*** Bug 49668 has been marked as a duplicate of this bug. ***
>= 20040113 FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_MESSAGESEND_ARGUMENTS added to White Space -> Expressions -> Method and constructor calls -> between empty parentheses
*** Bug 50845 has been marked as a duplicate of this bug. ***
Verified in 200402121200.