You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Neil C Smith (JIRA)" <ji...@apache.org> on 2018/02/06 11:10:00 UTC

[jira] [Commented] (NETBEANS-332) Code-format messes up file if it cannot be parsed

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

Neil C Smith commented on NETBEANS-332:
---------------------------------------

{quote}It takes a lot of effort to fix the formatting once the IDE messes it up.{quote}

While I don't disagree with the premise of this, surely the "lot of effort" involves hitting undo?  Or is there a circumstance where that doesn't apply?

> Code-format messes up file if it cannot be parsed
> -------------------------------------------------
>
>                 Key: NETBEANS-332
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-332
>             Project: NetBeans
>          Issue Type: Bug
>          Components: editor - Formatting &amp; Indentation
>         Environment: Product Version: Apache NetBeans IDE Dev (Build 20180117-unknown-revn)
> Updates: Updates available
> Java: 9.0.4; Java HotSpot(TM) 64-Bit Server VM 9.0.4+11
> Runtime: Java(TM) SE Runtime Environment 9.0.4+11
> System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb)
> User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
> Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev
>            Reporter: Gili
>            Priority: Major
>
> *Repro steps*:
>  # Given:
>  
> {code:java}
> public enu NoOpAllowPriceStep 
> {
>  INSTANCE;
>  public Order atMaximumPrice(BigDecimal price)
>  {
>    return null;
>  }
>  public Order atBestPrice()
>  {
>    return null;
>  }
> }
> {code}
> 2. Invoke code-format
> 3. File is reformatted as following:
> {code:java}
> public enu
> NoOpAllowPriceStep
> {
> INSTANCE;
> public Order
> atMaximumPrice
> (BigDecimal
> price
> )
>  {
>  return null;
> }
>  public Order
> atBestPrice
> ()
>  {
>  return null;
>  }
> }
> {code}
> *Expected behavior*: If file cannot be parsed, IDE should beep and refuse to reformat. The file contents should not be changed.
> *Justification*: If code-format rearranges tokens, then user corrects the compiler error, then invokes code-format again, he/she will not end up with the same result as if they had corrected the compiler error in the first place and invoked code-format. It takes a lot of effort to fix the formatting once the IDE messes it up.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

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