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

2018-02-06 Thread Gili (JIRA)

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

Gili commented on NETBEANS-332:
---

[~neilcsmith] Typically, that's what I do but it's not always obvious that the 
IDE has screwed up the file until it's too late. Sometimes an error occurs 
somewhere near the top of the file but the formatting corruption occurs way 
down the file. So you continue editing only to discover much later 
(commit/diff) that the bottom half of the file is screwed up :)

> 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  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-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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



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

2018-02-06 Thread Neil C Smith (JIRA)

[ 
https://issues.apache.org/jira/browse/NETBEANS-332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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  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-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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