Bug 265192 - [formatter] Java Annotations not formatted correctly
Summary: [formatter] Java Annotations not formatted correctly
Status: VERIFIED DUPLICATE of bug 198074
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-17 13:07 EST by Andrew Heron CLA
Modified: 2009-08-10 12:56 EDT (History)
3 users (show)

See Also:


Attachments
Formatter Preferences (27.85 KB, text/xml)
2009-02-18 06:03 EST, Andrew Heron CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.