This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 131069 - Incorrect brace elimination for nested IF
Summary: Incorrect brace elimination for nested IF
Status: RESOLVED DUPLICATE of bug 123258
Alias: None
Product: ide
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: issues@ide
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-25 17:19 UTC by kduling
Modified: 2008-03-25 17:48 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


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 ***