Bug 241687 - [formatter] problem formatting block comments
Summary: [formatter] problem formatting block comments
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Server 2003
: P3 normal (vote)
Target Milestone: 3.4.1   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-22 11:35 EDT by João Kreuzberg CLA
Modified: 2008-09-16 05:18 EDT (History)
6 users (show)

See Also:


Attachments
Proposed patch (2.44 KB, patch)
2008-08-21 04:50 EDT, Frederic Fusier CLA
no flags Details | Diff
Proposed patch for R3_4_maintenance branch (2.72 KB, patch)
2008-08-21 12:17 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description João Kreuzberg CLA 2008-07-22 11:35:00 EDT
Build ID: Build id: I20080617-2000

Steps To Reproduce:
Formatting source is not keeping the correct format.
Looking at More Information and you will see what's happening. The same comment snippet used to work on eclipse 3.3. 

Tried to export preferences from eclipse 3.3 and import to eclipse 3.4 also didn't work (ketan mentioned).

On eclipse 3.3 I was using eclipse built-in code formatter and that code snippet always worked on 3.x.



More information:
3.4
	 
/*
 * ---------------------------------------------------------- END OF SETS
 * AND GETS----------------------------------------------------------
 */
 
3.3
 
/*----------------------------------------------------------
 * SETS AND GETS
 *----------------------------------------------------------*/
 
 
 
3.4 Enabled block comment disabled
/*----------------------------------------------------------
 * END OF SETS AND GETS
 * test test test test test test test test test test test test test test test test test test test test test 
 * 
*
 *----------------------------------------------------------*/
Comment 1 João Kreuzberg CLA 2008-07-22 11:36:39 EDT
(In reply to comment #0)
> Build ID: Build id: I20080617-2000
> 
> Steps To Reproduce:
> Formatting source is not keeping the correct format.
> Looking at More Information and you will see what's happening. The same comment
> snippet used to work on eclipse 3.3. 
> 
> Tried to export preferences from eclipse 3.3 and import to eclipse 3.4 also
> didn't work (ketan mentioned).
> 
> On eclipse 3.3 I was using eclipse built-in code formatter and that code
> snippet always worked on 3.x.
> 
> 
> 
> More information:
> 3.4
> 
> /*
>  * ---------------------------------------------------------- END OF SETS
>  * AND GETS----------------------------------------------------------
>  */
> 
> 3.3
> 
> /*----------------------------------------------------------
>  * SETS AND GETS
>  *----------------------------------------------------------*/
> 
> 
> 
> 3.4 Enabled block comment disabled
> /*----------------------------------------------------------
>  * END OF SETS AND GETS
>  * test test test test test test test test test test test test test test test
> test test test test test test 
>  * 
> *
>  *----------------------------------------------------------*/
> 

--> 3.4 Enabled block comment disabled* -> Block comment disabled

Comment 2 Frederic Fusier CLA 2008-08-18 09:59:30 EDT
Im' not sure to really get your test case... It seems that the initial comment (i.e. before formatting) is:
/*----------------------------------------------------------
 * END OF SETS AND GETS
 * test test test test test test test test test test test test test test test
test test test test test test 
 * 
*
 *----------------------------------------------------------*/
as you said it's the result when the block comment preference is disabled.

Wat it really the comment you formatted? If so, how could you get:
/*
 * ---------------------------------------------------------- END OF SETS
 * AND GETS----------------------------------------------------------
 */
with 3.4 formatter?

and:
/*----------------------------------------------------------
 * SETS AND GETS
 *----------------------------------------------------------*/
with 3.3 one?

Could you also precise what is the profile used while formatting (Eclipse/Java conventions built-in or specific one)?

Thanks
Comment 3 João Kreuzberg CLA 2008-08-18 11:29:28 EDT
I was using Eclipse built-in profile.

But I tried with all others and the same thing was happening.

Regarding Eclipse 3.3:

Version: 3.3.2
Build id: M20080221-1800
Comment 4 Frederic Fusier CLA 2008-08-20 11:55:15 EDT
(In reply to comment #3)
> I was using Eclipse built-in profile.
> 
> But I tried with all others and the same thing was happening.
> 
> Regarding Eclipse 3.3:
> 
> Version: 3.3.2
> Build id: M20080221-1800
> 
I was also asking for a clarification of your test case...
There's not only formatting between initial comment and the outputs of 3.3 and 3.4 versions, is there?
Comment 5 Frederic Fusier CLA 2008-08-20 12:26:19 EDT
OK, assuming that the initial test case is:
/*---------------------
 * END OF SETS AND GETS
 * test test test test test test test
test test test test test test 
 * 
*
 *---------------------*/

Using Eclipse built-in + 'Maximum line width for comments' = 40
The output with 3.3 formatter is:
	/*---------------------
	 * END OF SETS AND GETS
	 * test test test test test test test
	 test test test test test test 
	 * 
	 *
	 *---------------------*/

although with 3.4 formatter it is:
	/*
	 * --------------------- END OF SETS
	 * AND GETS test test test test test
	 * test test test test test test
	 * test test
	 * 
	 * 
	 * ---------------------
	 */

It seems that bug 230944 was not completely fixed. When /*- is followed by another dash, the formatter still does not respect the tacit contract not to format the block comment...

It works for all other characters than '-', I'll investigate...
Comment 6 Frederic Fusier CLA 2008-08-21 04:48:51 EDT
While formatting the block comment, the scribe looks at the token just after the starting /*. Currently if does not format the comment if the token is TokenNameMINUS, but it must also do the same when the token is TokenNameMINUS_MINUS which is the case for this bug...
Comment 7 Frederic Fusier CLA 2008-08-21 04:50:49 EDT
Created attachment 110537 [details]
Proposed patch
Comment 8 Frederic Fusier CLA 2008-08-21 04:53:39 EDT
Released for 3.5M2
Comment 9 Frederic Fusier CLA 2008-08-21 05:35:01 EDT
Jerome, can we consider this fix to be backported to 3.4.1 as this is a regression since 3.3.2? There's no data loss but the benefit would be interesting as I found several block comments with this pattern in Ganymede source files...
Comment 10 Jerome Lanneluc CLA 2008-08-21 05:50:19 EDT
+1 for 3.4.1 since this is a regression comparing to 3.3.2
Comment 11 Frederic Fusier CLA 2008-08-21 12:17:13 EDT
Created attachment 110588 [details]
Proposed patch for R3_4_maintenance branch
Comment 12 Frederic Fusier CLA 2008-08-21 12:17:43 EDT
Released for 3.4.1
Comment 13 Olivier Thomann CLA 2008-08-28 12:59:15 EDT
Verified for 3.4.1 using M20080827-2000
Comment 14 David Audel CLA 2008-09-16 05:18:16 EDT
Verified for 3.5M2 using I20080914-2000