Gili created NETBEANS-332:
-----------------------------

             Summary: 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


1. Given:

 
{code:java}
public enu NoOpAllowPriceStep 
{
INSTANCE;
 public Order atMaximumPrice(BigDecimal price)
 {
 return null;
 }
@Override
 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;
}
@Override
 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

Reply via email to