Bug 265192

Summary: [formatter] Java Annotations not formatted correctly
Product: [Eclipse Project] JDT Reporter: Andrew Heron <andrew.heron>
Component: CoreAssignee: Frederic Fusier <frederic_fusier>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: markus.kell.r, Olivier_Thomann, srikanth_sankaran
Version: 3.4.1   
Target Milestone: 3.5 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Formatter Preferences none

Description Andrew Heron CLA 2009-02-17 13:07:27 EST
Build ID:  M20080911-1700

Steps To Reproduce:
1. Enter the following code to a class
    
@ManyToOne
@JoinColumns ({
        @JoinColumn (name = "join1", referencedColumnName = "column1"),
        @JoinColumn (name = "join2", referencedColumnName = "column2")
})
private Foo foo;

2. Run code formatter, all formatting is lost.

More information:
There is no way (that I can see) of setting up the code formatter to format the code to look like this.
Can an Annotation section be added to 'Line Wrapping'  with options "Keep original wrapping", "Wrap when necessary"?
Also, a subsection "Annotations -> Array initializers" with options "Keep original wrapping", "Wrap when necessary", "Wrap first, others when necessary" ... and all others currently under "Expressions -> Array Initializers".
Another subsection "Annotations -> String concatenation" with approriate wrapping policies would be useful to format queries embedded within @NamedQuery
Comment 1 Frederic Fusier CLA 2009-02-18 05:38:25 EST
Using Eclipse [built-in] profile, the formatter output does not break the formatting of your snippet, it just indent the lines and replace the spaces with tabulations.

Could you provide your profile and the corresponding formatter output showing that the formatting is lost?

Thanks
Comment 2 Andrew Heron CLA 2009-02-18 06:03:42 EST
Created attachment 126009 [details]
Formatter Preferences

The attached preferences changes my code to 
@ManyToOne
@JoinColumns ( {@JoinColumn (name = "join1", referencedColumnName = "column1"), @JoinColumn (name = "join2", referencedColumnName = "column2")})
Comment 3 Frederic Fusier CLA 2009-06-22 10:45:51 EDT
I think the 'Never join lines' would fix your problem (you'll find it on the 'Line Wrapping' preferences tab.

Using it on top of your profile, I get the following output for the comment 0 snippet:

    @ManyToOne
    @JoinColumns ({
            @JoinColumn (name = "join1", referencedColumnName = "column1"),
            @JoinColumn (name = "join2", referencedColumnName = "column2")})
    private String foo;

So, I set this bug as duplicate of bug 198074, please reopen if you disagree, thx


*** This bug has been marked as a duplicate of bug 198074 ***
Comment 4 Srikanth Sankaran CLA 2009-08-05 02:19:26 EDT
Verified for 3.6M1 using I20090803-1800
Comment 5 Olivier Thomann CLA 2009-08-10 12:56:06 EDT
Verified.