Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357300

Summary: Function parameter line wrapping wraps commas separating parameters
Product: [Tools] CDT Reporter: Aaron Sabelko <aaron.sabelko>
Component: cdt-editorAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse.sprigogin
Version: 8.0   
Target Milestone: 8.0.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Demonstrates function parameter line wrapping behavior none

Description Aaron Sabelko CLA 2011-09-09 22:54:14 EDT
Build Identifier: 8.0.0.201106081058

When there's a comma in a function parameter list that is not separating function parameters and the function parameter line wrapping policy is something other than "do not wrap", the commas that separate function parameters wrap instead of remaining on the line of the previous parameter.

For example, this is the result of formatting with a "do not wrap" function parameter line wrapping policy:

void do_not_wrap(more_than_one_template_argument_t<int, float> p1, no_template_arguments_t p2, no_template_arguments_t p3) {
}

Here is the result of formatting with the "wrap only when necessary" policy:

void wrap_when_necessary(more_than_one_template_argument_t<int, float> p1
		, no_template_arguments_t p2, no_template_arguments_t p3) {
}



Reproducible: Always

Steps to Reproduce:
1. Create function whose declaration or definition exceeds the maximum line length.
2. Set the line wrapping policy of function parameters to something other than "do not wrap".
3. Run formatter.
Comment 1 Aaron Sabelko CLA 2011-09-09 22:56:35 EDT
Created attachment 203102 [details]
Demonstrates function parameter line wrapping behavior
Comment 2 Anton Leherbauer CLA 2011-09-12 03:55:31 EDT
Thanks for the test case. That's a regression compared to 7.0.2.
Comment 3 Anton Leherbauer CLA 2011-09-21 08:50:53 EDT
Fixed in master and cdt_8_0.
Sergey, could you review the fix if you see any potential problems with it? JUnit tests are green, but one never knows. Thanks.
Comment 4 CDT Genie CLA 2011-09-21 09:23:01 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 357300 - Function parameter line wrapping wraps commas separating parameters

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=cd17d74157b9c6bb56241efb848b4238e2519e04
Comment 5 CDT Genie CLA 2011-09-21 09:23:03 EDT
*** cdt git genie on behalf of Anton Leherbauer ***

    Bug 357300 - Function parameter line wrapping wraps commas separating parameters

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=5c47f3f1a1317b4deac1407f7dac5b0de4d057f9
Comment 6 Sergey Prigogin CLA 2011-09-21 20:29:55 EDT
(In reply to comment #3)
The fix unfortunately is incorrect since the tail formatter has to be set before calling node.accept(this) on the argument node. I've implemented a different fix and added a test case that would have caught the regression.
Comment 7 CDT Genie CLA 2011-09-21 22:23:02 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 357300 - Function parameter line wrapping wraps commas separating
    parameters. Corrected fix.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=e700877818c70b9a89d0a88c47f7add6619ff009
Comment 8 CDT Genie CLA 2011-09-21 22:23:03 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 357300 - Function parameter line wrapping wraps commas separating
    parameters. Corrected fix.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=4bca28c52f40256f0f962e3c4477c1beacc02e5e
Comment 9 CDT Genie CLA 2011-09-22 00:23:01 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 357300. Stricter test case.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=baacf46add1ac5c8db7a367ea6151719fc320f48
Comment 10 CDT Genie CLA 2011-09-22 00:23:02 EDT
*** cdt git genie on behalf of Sergey Prigogin ***

    Bug 357300. Stricter test case.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=2deffc716f877e380771c42382a60703720441d3
Comment 11 Anton Leherbauer CLA 2011-09-22 02:51:55 EDT
(In reply to comment #6)
> (In reply to comment #3)
> The fix unfortunately is incorrect since the tail formatter has to be set
> before calling node.accept(this) on the argument node. I've implemented a
> different fix and added a test case that would have caught the regression.

Thanks, I suspected there must be a reason to set it before node.accept().