Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 131069 - Incorrect brace elimination for nested IF
Incorrect brace elimination for nested IF
Status: RESOLVED DUPLICATE of bug 123258
Product: ide
Classification: Unclassified
Component: Code
6.x
PC Windows XP
: P3 (vote)
: TBD
Assigned To: issues@ide
issues@ide
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-03-25 17:19 UTC by kduling
Modified: 2008-03-25 17:48 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description kduling 2008-03-25 17:19:30 UTC
Under Options -> Java Code -> Formatting -> Alignment & Braces -> Braces Generation, selecting "Eliminate" for "if"
introduces incorrect branching.

Example:

  public void update()
  {
    // Update the player's bat position
    final int keyState = getKeyStates();
    if ((keyState & GameCanvas.LEFT_PRESSED) != 0)
    {
      if (playerBat.getRefPixelX() - 5 > BAT_SPEED)
      {
        playerBat.move(-BAT_SPEED, 0);
      }
    }
    else if ((keyState & GameCanvas.RIGHT_PRESSED) != 0)
    {
      if (playerBat.getRefPixelX() + 15 < screenWidth - BAT_SPEED)
      {
        playerBat.move(BAT_SPEED, 0);
      }
    }

becomes

  public void update()
  {
    // Update the player's bat position
    final int keyState = getKeyStates();
    if ((keyState & GameCanvas.LEFT_PRESSED) != 0)
      if (playerBat.getRefPixelX() - 5 > BAT_SPEED)
        playerBat.move(-BAT_SPEED, 0);
    else if ((keyState & GameCanvas.RIGHT_PRESSED) != 0)
      if (playerBat.getRefPixelX() + 15 < screenWidth - BAT_SPEED)
        playerBat.move(BAT_SPEED, 0);
  }
Comment 1 kduling 2008-03-25 17:48:15 UTC

*** This issue has been marked as a duplicate of 123258 ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo