You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2017/11/24 11:06:00 UTC

[jira] [Commented] (NETBEANS-97) Improve java source reformatting of try and synchronized blocks with control structures

    [ https://issues.apache.org/jira/browse/NETBEANS-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16265163#comment-16265163 ] 

ASF GitHub Bot commented on NETBEANS-97:
----------------------------------------

sdedic commented on issue #173: [NETBEANS-97] Don't add braces around try/synchronized blocks when reformatting
URL: https://github.com/apache/incubator-netbeans/pull/173#issuecomment-346803477
 
 
   I would also prefer to add an user option for the behaviour. Usage of { depends on group's code style should be somehow enformed.
   But in any case, add relevant test cases to org.netbeans.modules.java.source.save.FormatingTest

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Improve java source reformatting of try and synchronized blocks with control structures
> ---------------------------------------------------------------------------------------
>
>                 Key: NETBEANS-97
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-97
>             Project: NetBeans
>          Issue Type: Improvement
>          Components: java - Source
>    Affects Versions: 9.0
>            Reporter: mike duigou
>            Assignee: mike duigou
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 9.0
>
>
> This issue recreates [https://netbeans.org/bugzilla/show_bug.cgi?id=269050 Netbeans bug 269050]. New bug database, new hope for integration!
> Currently the java source reformatter (java.source.base org.netbeans.modules.java.source.save.Reformatter) does not treat try and synchronized blocks as blocks when it encounters them with control structures. So
> {code:java}
> if (foo == bar) try {
>    baz();
> } catch (Exception all) {
>    log.(....);
> }
> {code}
> is reformatted as :
> {code:java}
> if (foo == bar) {
>   try {
>     baz();
>   } catch (Exception all) {
>     log.(....);
>   }
> }
> {code}
> The additional added basic block layer is not needed as the try is already a block. The same applies for a synchronized block as well.
> {code:java}
> if (foo == bar) synchronized(quux) {
>    baz();
> }
> {code}
> is currently reformatted as :
> {code:java}
> if (foo == bar) {
>   synchronized(quux) {
>     baz();
>   }
> }
> {code}
> In addition to "if/else" this formatting all affects other control structures such as "for", "for-each" and "while".
> Line breaks are preserved so existing source 
> {code:java}
> if (foo == bar) {
>   synchronized(quux) {
>     baz();
>   }
> }
> {code}
> will be reformatted with line breaks intact--only the braces will be removed 
> {code:java}
> if (foo == bar) 
>   synchronized(quux) {
>     baz();
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)