Bug 254998 - [formatter] wrong type comment format during code generation
Summary: [formatter] wrong type comment format during code generation
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 265898 268974 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-12 04:26 EST by Sven Krause CLA
Modified: 2009-03-17 09:55 EDT (History)
5 users (show)

See Also:


Attachments
Sample project scenario. (26.37 KB, application/x-zip-compressed)
2008-11-12 04:26 EST, Sven Krause CLA
no flags Details
Proposed patch (19.35 KB, patch)
2009-01-09 09:48 EST, 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 Sven Krause CLA 2008-11-12 04:26:13 EST
Created attachment 117640 [details]
Sample project scenario.

Build ID: I20080617-2000

EMF: 2.4.0.v200806091234

Steps To Reproduce:
1. Set "Coder Formatter" = true within genmodel
2. Set "Format Header" = true within java code style comments page
3. Generate 


More information:
The comment style within all files will be generated as block instead of javadoc style with the consequence that overriding the @generate annotoation will be ignored.

So Far I'v seen is the problem located with the double interpretation of the comment_format_header flag within the JDT code formatter (org.eclipse.jdt.internal.formatter.Scribe.includesJavadocComments()). 
(org.eclipse.jdt.internal.formatter.Scribe.printComment(int): line 1873).
But the error happens only while code formatting during code gen from EMF not applied as JDT editor / package explorer action.
Comment 1 Ed Merks CLA 2008-12-16 07:52:43 EST
Looking at the behavior I finally figured that changing to specify F_INCLUDE_COMMENTS seemed to help, but this seems to cause formatting of comments even if all the preferences say not to do that

((CodeFormatter)codeFormatter).format(CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, doc.get(), 0, doc.get().length(), 0, null);


I think it's actually a more fundamental problem in the formatter itself.  Here's what I noticed. Go to the Comments tab of the formatter preferences and uncheck all the "General settings" boxes.  Then check "Enable header formatting".  Note that not only does the header format (a good thing), but the Javadoc comment on "interface Example" turns into a block comment; this is exactly the same symptom as being reported for this bug.  If you also check "Enable block comment formatting" all the Javadoc comments are converted to block comments.

So I'm assuming that if the bad behavior on the preferences page is fixed that the bad behavior manifested by EMF's uses of the formatter will also be fixed.

This problem occurs in the 3.4.x stream and the 3.5 stream.
Comment 2 Frederic Fusier CLA 2009-01-09 09:48:42 EST
Created attachment 122118 [details]
Proposed patch

Note that this patch also includes fixes for bug 239607 and bug 260276 which were faced while running tests...
Comment 3 Frederic Fusier CLA 2009-01-09 10:11:12 EST
Released for 3.5M5.
Comment 4 Srikanth Sankaran CLA 2009-01-27 05:29:50 EST
Verified for 3.5M5 using I20090125-2000 build
Comment 5 Frederic Fusier CLA 2009-02-24 11:39:39 EST
*** Bug 265898 has been marked as a duplicate of this bug. ***
Comment 6 Ed Merks CLA 2009-03-17 09:55:30 EDT
*** Bug 268974 has been marked as a duplicate of this bug. ***