Bug 232788 - [formatter] Formatter misaligns stars when formatting block comments
Summary: [formatter] Formatter misaligns stars when formatting block comments
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.4 RC2   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-05-19 09:20 EDT by Claudio Nieder CLA
Modified: 2008-05-23 06:04 EDT (History)
4 users (show)

See Also:
jerome_lanneluc: review+
eric_jodet: review+


Attachments
Fromatter configuration (28.13 KB, application/xml)
2008-05-19 10:16 EDT, Claudio Nieder CLA
no flags Details
Proposed patch (16.22 KB, patch)
2008-05-21 10:12 EDT, Frederic Fusier CLA
no flags Details | Diff
Proposed patch updated with last HEAD contents (16.22 KB, patch)
2008-05-21 10:24 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 Claudio Nieder CLA 2008-05-19 09:20:44 EDT
Build ID: I20080516-1333

Steps To Reproduce:
1. Take a Java source with a block comment like
/*
 * Hello
 */

2. Use Source->Format

3. Observer that the comment now looks like this:

 /*
   * Hello
   */



More information:
I first observed it I think with 3.4M7. It is still in I20080516-1333.

I have added an export of my formatter configuration, in case that matters.
Comment 1 Dani Megert CLA 2008-05-19 09:44:54 EDT
Cannot reproduce using 3.4 RC1. Can you attach a complete example and also
attach your formatter settings? Thanks.
Comment 2 Claudio Nieder CLA 2008-05-19 10:16:57 EDT
Created attachment 100913 [details]
Fromatter configuration

Sorry, seems attaching didn't work when I submitted the bug.
Comment 3 Claudio Nieder CLA 2008-05-19 10:22:11 EDT
I just tried to reproduce it myself with a copletly fresh install and a completly new unix user and have seen, that I could only reproduce it after importing my own formatter configuration.
Comment 4 Claudio Nieder CLA 2008-05-19 10:47:24 EDT
I could reproduce the bug in fresh install of eclipse-SDK-I20080516-1333-linux-gtk.tar.gz without using my formatter configuration with these steps:

Enter the workspace.

Create a new project Test: File -> New -> Java Project
Create a new class Test: File -> New -> Class

Make the class look like

public class Test {
/*
 * Hello
 */
}

Change the formatter settings: Windows -> Preferences -> Java -> Code Style -> Formatter

Edit the "Eclipse [built-in]" format and just set a new profile name and change in the Indentation Tab the "Tab policy" to "Spaces only" and "Indentation size" to 1. Accept and return to workspace

Format with Source -> Format


Probably only "Indentation size" needs to be set to 1.
Comment 5 Frederic Fusier CLA 2008-05-19 11:31:16 EDT
Thanks for the steps, I can reproduce it now. I'll investigate. Note that this is a regression introduced by the new comments formatter as this issue does not occur in 3.3 .
Comment 6 Frederic Fusier CLA 2008-05-19 11:33:47 EDT
Note that this does not happen while formatting javadoc comment:
public class Test {
/**
 * Hello
 */
}

is correctly formatted as:
public class Test {
 /**
  * Hello
  */
}

Comment 7 Claudio Nieder CLA 2008-05-19 12:34:36 EDT
Indeed. I have only issues with /* block */ comments, none with /** javadoc */ or // line comments. Sorry for not having stated it clearly enough.
Comment 8 Frederic Fusier CLA 2008-05-19 13:14:22 EDT
(In reply to comment #7)
> Indeed. I have only issues with /* block */ comments, none with /** javadoc */
> or // line comments. Sorry for not having stated it clearly enough.
> 
No problem, we appreciate the time you spent to find a reproducible test case, that helps a lot!
Comment 9 Frederic Fusier CLA 2008-05-21 10:12:50 EDT
Created attachment 101266 [details]
Proposed patch
Comment 10 Frederic Fusier CLA 2008-05-21 10:16:22 EDT
Jerome, I would propose this patch to be put in RC2 as it fix a regression vs 3.3 formatting and also fixes potential ArithmeticException: "/ by zero" when tab length is set to 0 (3.3 has similar issue when setting the indentation size to 0)!
Comment 11 Frederic Fusier CLA 2008-05-21 10:24:37 EDT
Created attachment 101272 [details]
Proposed patch updated with last HEAD contents
Comment 12 Jerome Lanneluc CLA 2008-05-22 05:12:04 EDT
Since this is a regression comparing to 3.3.2, ok to fix it for RC2
Comment 13 Frederic Fusier CLA 2008-05-22 07:07:02 EDT
Jerome, Eric, could you please review?
Comment 14 Eric Jodet CLA 2008-05-22 09:11:54 EDT
Patch looks good: +1
Comment 15 Jerome Lanneluc CLA 2008-05-22 11:38:03 EDT
Looks good: +1
Comment 16 Frederic Fusier CLA 2008-05-22 11:54:15 EDT
Released for 3.4RC2 in HEAD stream.
Comment 17 Eric Jodet CLA 2008-05-23 06:04:28 EDT
verified for 3.4RC2 using build I20080523-0100