Bug 257906

Summary: [Formatter] should have separate 'preserve existing line breaks' for code and comment formatting
Product: [Eclipse Project] JDT Reporter: Dani Megert <daniel_megert>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: jerome_lanneluc
Version: 3.5   
Target Milestone: 3.5 M4   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Fixed proposed patch none

Description Dani Megert CLA 2008-12-08 06:29:51 EST
I20081202-1812.

So far users could set their code and comment formatter options independent from each other. We should keep this tradition and have separate 'preserve existing line breaks' for code and comment formatting.
Comment 1 Frederic Fusier CLA 2008-12-08 07:02:06 EST
Here's the new formatter constant proposal:
/**
 * <pre>
 * FORMATTER / Option to specify whether the formatter should preserve existing line breaks in comments or not
 * 
 * 		For example, the following comment:
 * 			/**
 * 			 * The foo method.
 * 			 * foo is a substitute for bar.
 * 			 *&#0047;
 * 			public class X {
 * 			}
 * 
 * 		will be unchanged by the formatter when this new preference is used.
 *
 *     - option id:         "org.eclipse.jdt.core.formatter.preserve_existing_comments_line_breaks"
 *     - possible values:   { TRUE, FALSE }
 *     - default:           FALSE
 * </pre>
 * @since 3.5
 */
public static final String FORMATTER_PRESERVE_EXISTING_COMMENTS_LINE_BREAKS = JavaCore.PLUGIN_ID + ".formatter.preserve_existing_comments_line_breaks";	//$NON-NLS-1$
Comment 2 Dani Megert CLA 2008-12-08 07:04:27 EST
What about: FORMATTER_DO_NOT_JOIN_LINES_IN_COMMENTS
Comment 3 Dani Megert CLA 2008-12-08 07:14:22 EST
I suggested 'FORMATTER_DO_NOT_JOIN_LINES_IN_COMMENTS' because I think it's closer to what it does. Even with the Javadoc from comment 1 it is not clear to the client what happens e.g. with the 'remove blank lines' option as those are also existing line breaks.
Comment 4 Frederic Fusier CLA 2008-12-08 07:29:02 EST
(In reply to comment #3)
> I suggested 'FORMATTER_DO_NOT_JOIN_LINES_IN_COMMENTS' because I think it's
> closer to what it does. Even with the Javadoc from comment 1 it is not clear to
> the client what happens e.g. with the 'remove blank lines' option as those are
> also existing line breaks.
> 
Good point, blank lines are also line breaks but are effectively not preserved when 'remove blank lines' option is set...

Jerome, do you also agree?
Comment 5 Jerome Lanneluc CLA 2008-12-08 07:46:57 EST
Instead of having a negative constant name, what about "FORMATTER_JOIN_LINES_IN_COMMENTS" with a default set to TRUE ?
Comment 6 Dani Megert CLA 2008-12-08 08:05:32 EST
>"FORMATTER_JOIN_LINES_IN_COMMENTS" with a default set to TRUE ?
Would also be OK for me.
Comment 7 Frederic Fusier CLA 2008-12-08 09:38:55 EST
Created attachment 119787 [details]
Proposed patch

This patch also fixes bug 257907...
Comment 8 Frederic Fusier CLA 2008-12-08 09:51:46 EST
Created attachment 119790 [details]
Fixed proposed patch

Ooops, I forgot to remove the unexpected specific option for javadoc comments...
This new patch is clean now.
Comment 9 Dani Megert CLA 2008-12-08 09:55:30 EST
Patch works for me.
Comment 10 Frederic Fusier CLA 2008-12-08 11:12:02 EST
Released for 3.5M4 in HEAD stream.
Comment 11 Kent Johnson CLA 2008-12-09 13:43:48 EST
Verified for 3.5M4 using I20081209-0100