Bug 207809 - [formatter] Code Formatter does not wrap Java-annotation parameters
Summary: [formatter] Code Formatter does not wrap Java-annotation parameters
Status: VERIFIED DUPLICATE of bug 282030
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows XP
: P3 normal with 8 votes (vote)
Target Milestone: 3.6 M6   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-29 12:58 EDT by Joerg Mueller CLA
Modified: 2010-08-04 02:11 EDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joerg Mueller CLA 2007-10-29 12:58:22 EDT
Build ID: M20071023-1652

Steps To Reproduce:
1.Create some code that has annotations with long parameter lists. This is very likely when using Hibernate. Please see the following example class:

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * An example class that uses Hibernate Annotations that have long annotation parameters, which will not be wrapped by
 * the Eclipse Code-Formatter
 */
@Table(uniqueConstraints = @UniqueConstraint(columnNames = { "_id", "_column" }))
@Entity
public class ExampleEntity
{
    @Id
    @GeneratedValue(generator = "ExampleSequence")

    // The following line shows the wrapping problem
    @GenericGenerator(name = "ExampleSequence", strategy = "org.hibernate.id.SequenceGenerator", parameters = { @Parameter(name = "sequence", value = "example_seq"),
                                                                                                               @Parameter(name = "parameters", value = "minvalue 1 maxvalue 9999999999 start with 1 increment by 1 cache 20") })
    // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    /* The Code Formatter should allow parameters per line like this:
     *
     * @GenericGenerator(name = "ExampleSequence",
     *                   strategy = "org.hibernate.id.SequenceGenerator",
     *                   parameters = { @Parameter(name = "sequence", value = "example_seq"),
     *                                  @Parameter(name = "parameters",
     *                                             value = "minvalue 1 maxvalue 9999999999 start with 1 increment by 1 cache 20") })
     *
     */


    private Long _id;

    @Column(name = "asset_equals_id", nullable = false)
    private String _column;

}

2. Try to format it using the Java code-formatter. The formatter will not wrap the parameters in Line 23. There also is no option in code formatting rules for wrapping annotation parameters like it is for methods and other elements.

(For this class to compile you would need persistence-api-1.0.jar and hibernate-annotations-3.2.1.ga.jar in your classpath. Code Formatter should work without them) 



More information:
Comment 1 Eric Jodet CLA 2007-11-07 06:39:14 EST
see also bug 207330
Comment 2 Joerg Mueller CLA 2007-11-07 08:38:13 EST
Just to prevent misunderstandings, as far as I understand bug 207330 is about 
annotations on method parameters like:

method(@annotation parameter)

This bug is about parameters of annotations like:

@annotation(parameter, parameter)  

I don't know about similarities in the eclipse implementation but from a user perspective this looks different.
Comment 3 Frederic Fusier CLA 2010-07-01 11:14:08 EDT
I missed this duplicate while fixing bug 282030...

*** This bug has been marked as a duplicate of bug 282030 ***
Comment 4 Srikanth Sankaran CLA 2010-08-04 02:11:45 EDT
Verified for 3.7 M1 using build I20100802-1800