[ 
https://issues.apache.org/jira/browse/NETBEANS-6275?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Brett Ryan updated NETBEANS-6275:
---------------------------------
    Description: 
When auto-formatting record classes there are a few behavioural elements that 
make it inconsistent or hard to control.

The compact constructor always adds multiple spaces between the name and the 
constructors opening brace. This is somehow related to how long the records 
parameters are.
{code:java}
record Widget(String name, int width, int length) {

    // note the additional spaces between t and {
    Widget   {
    }

}
{code}
There is no easy way to create records with less lines, such as a standard 
record which has no constructors or additional logic. One may wish to create 
the record with an empt body like the following:

{code:java}
record Widget(String name, int width, int length) {}
{code}

However, the formatter will always put an empty line between the braces. This 
is expected due to it using the class level parameters for 1 space after class 
header and 1 before closing brace, which is perfect for classes but makes most 
records a little horizontally larger which is most evident for records declared 
in classes.

It's not possible to put the opening record brace on a new line, as in the 
following:

{code:java}
record Widget(
    String name,
    int width,
    int length
) {

    Widget {
        requireNonNull(name);
    }

}
{code}

  was:
When auto-formatting record classes there are a few behavioural elements that 
make it inconsistent or hard to control.

The compact constructor always adds multiple spaces between the name and the 
constructors opening brace. This is somehow related to how long the records 
parameters are.
{code:java}
record Widget(String name, int width, int length) {

    // note the additional spaces between t and {
    Widget   {
    }

}
{code}
There is no easy way to create records with less lines, such as a standard 
record which has no constructors or additional logic. One may wish to create 
the record with an empt body like the following:

 {code:java}
record Widget(String name, int width, int length) {}
{code}

However, the formatter will always put an empty line between the braces. This 
is expected due to it using the class level parameters for 1 space after class 
header and 1 before closing brace, which is perfect for classes but makes most 
records a little horizontally larger which is most evident for records declared 
in classes.

It's not possible to put the opening record brace on a new line, as in the 
following:

{code:java}
record Widget(
    String name,
    int width,
    int length
) {

    Widget {
        requireNonNull(name);
    }

}



> Add formatting options for record classes
> -----------------------------------------
>
>                 Key: NETBEANS-6275
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-6275
>             Project: NetBeans
>          Issue Type: Improvement
>          Components: editor - Formatting & Indentation
>    Affects Versions: 12.5, 12.6
>         Environment: *Product Version:* Apache NetBeans IDE 12.6
> *Java:* 17.0.1; Java HotSpot(TM) 64-Bit Server VM 17.0.1+12-LTS-39
> *Runtime:* Java(TM) SE Runtime Environment 17.0.1+12-LTS-39
> *System:* Mac OS X version 11.6.1 running on x86_64; UTF-8; en_AU (nb)
> *User directory:* /Users/brettryan/Library/Application Support/NetBeans/12.6
> *Cache directory:* /Users/brettryan/Library/Caches/NetBeans/12.6
>            Reporter: Brett Ryan
>            Priority: Minor
>
> When auto-formatting record classes there are a few behavioural elements that 
> make it inconsistent or hard to control.
> The compact constructor always adds multiple spaces between the name and the 
> constructors opening brace. This is somehow related to how long the records 
> parameters are.
> {code:java}
> record Widget(String name, int width, int length) {
>     // note the additional spaces between t and {
>     Widget   {
>     }
> }
> {code}
> There is no easy way to create records with less lines, such as a standard 
> record which has no constructors or additional logic. One may wish to create 
> the record with an empt body like the following:
> {code:java}
> record Widget(String name, int width, int length) {}
> {code}
> However, the formatter will always put an empty line between the braces. This 
> is expected due to it using the class level parameters for 1 space after 
> class header and 1 before closing brace, which is perfect for classes but 
> makes most records a little horizontally larger which is most evident for 
> records declared in classes.
> It's not possible to put the opening record brace on a new line, as in the 
> following:
> {code:java}
> record Widget(
>     String name,
>     int width,
>     int length
> ) {
>     Widget {
>         requireNonNull(name);
>     }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to