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 258348 - Double class name in generated switch statement code
Summary: Double class name in generated switch statement code
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Navigation (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Alexander Simon
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-13 22:05 UTC by Vladimir Kvashin
Modified: 2016-04-20 10:22 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 Vladimir Kvashin 2016-03-13 22:05:41 UTC
In the code example below, at the very end, there is a switch statement.
It switches through C++11 enum class enumerators
Its body is generated by the IDE.
Class name is printed twice - Token::Token::Kind::NUMBER instead of Token::Kind::NUMBER
Although it compiles OK, the code looks weird.

class Token {
public:
  enum class Kind {
    NUMBER,
    ALL,
    LAST,
    DBL_PERIOD,
    LPAREN,
    RPAREN,
    COMMA,
    MINUS,
    INVALID,
    EOD // end of data marker
  };
private:
  Token::Kind kind;
  int value;
public:
  Token(Token::Kind k, int v = 0);
  int getValue();
  Kind getKind();
  bool isValid();
  Token& operator=(const Token& other);
  Token(const Token& other);
};

class Tokenizer {
  const char* curr;
  bool errors;
public:
  Tokenizer(const char* Curr);
  bool HasErrors();
  Token NextToken();
};

void Parse(const char* rule) {
  Tokenizer tokenizer(rule);
  Token tok(Token::Kind::INVALID);
  while ((tok = tokenizer.NextToken()).isValid()) {
    switch (tok.getKind()) {
      // this switch body is generated
      case Token::Token::Kind::NUMBER: // should be Token::Kind::NUMBER
        break;
      case Token::Token::Kind::ALL: // should be Token::Kind::ALL
        break;
    // ...    
      default:
        break;
    }
  }
}
Comment 1 Alexander Simon 2016-03-21 10:36:10 UTC
fixed, change set:
http://hg.netbeans.org/cnd-main/rev/0f82909bdc72
Comment 2 Quality Engineering 2016-03-22 02:46:02 UTC
Integrated into 'main-silver', will be available in build *201603220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0f82909bdc72
User: Alexander Simon <alexvsimon@netbeans.org>
Log: fixed Bug #258348 Double class name in generated switch statement code
Comment 3 Vladimir Kvashin 2016-04-15 16:59:55 UTC
verified in builds on enum server
Comment 4 soldatov 2016-04-20 10:22:17 UTC
Verified in NetBeans 8.1 with latest updates.