Bug 198963

Summary: [formatter] 3.3 Code Formatter repeatedly indents block comment
Product: [Eclipse Project] JDT Reporter: trent cobham <trent>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: benno.baumgartner, jarthana
Version: 3.3   
Target Milestone: 3.5 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
New proposed patch none

Description trent cobham CLA 2007-08-06 13:32:45 EDT
Build ID: I20070621-1340

Steps To Reproduce:
1. Start with default Code Formatter settings: Eclipse: [built-in]
2. Set Indentation -> Tab Policy to 'Spaces only'
3. On Comments->General Settings turn OFF all 3 comment formatting settings.
4. Enter this code fragment:

public class test {

    int x = 0; /*
    * XXXX
    */
}

5. Run the formatter - the last two lines of the block comment are indented 3 spaces to the right.

6. Run the formatter AGAIN - the last two lines of the block comment are indented AGAIN. And so on...

7. Fragment after 6 executions of formatter looks like this:

public class test {

    int x = 0; /*
                      * XXXX
                      */

}


More information:
Comment 1 trent cobham CLA 2007-08-06 13:41:37 EDT
I forgot to say it worked ok in Eclipse 3.2 - inasmuch as it formatted the code only once to leave a 4-space indent before the last lines of the block comment:

    int x = 0; /*
     * For
     */

Repeated applications of the formatter did not change it further.

Comment 2 Benno Baumgartner CLA 2007-08-08 09:36:43 EDT
The code formatter is owned by core
Comment 3 Eric Jodet CLA 2008-02-26 01:22:59 EST
should be fixed with bug 102780
Comment 4 Frederic Fusier CLA 2008-05-18 11:37:11 EDT
(In reply to comment #3)
> should be fixed with bug 102780
> 
It's fixed when block formatting is set ON; you get following output at the first formatting and never change after even with several repetitions:
public class test {

    int x = 0; /*
                 * XXXX
                 */
}


However, the problem still occurs when it's OFF...
Comment 5 Frederic Fusier CLA 2009-02-26 12:29:40 EST
Created attachment 126872 [details]
Proposed patch
Comment 6 Frederic Fusier CLA 2009-02-27 10:09:01 EST
Created attachment 127007 [details]
New proposed patch

This patch is little bit less aggressive...

With previous patch, when the block comment was
/*
* comment
*/

a space was inserted before the beginning star of each line when the indentation was applied:
    /*
     * comment
     */

As it was not possible to know whether the comment initial indentation was intentional or not, I finally thought this was better to keep this behavior unchanged although the final result is less pretty than with previous patch... :-(

So, now the output is (as it was before the fix):
    /*
    * comment
    */
Comment 7 Frederic Fusier CLA 2009-02-27 10:09:23 EST
Released for 3.5M6 in HEAD stream.
Comment 8 Jay Arthanareeswaran CLA 2009-03-10 02:51:00 EDT
Verified for 3.5M6 with build I20090309-0100