Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Refactoring: Convert unscoped enum to scoped enum
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rpalma
Junior Member

Belgium
23 Posts

Posted - Mar 01 2018 :  04:33:10 AM  Show Profile  Reply with Quote
Hello,

It would be nice to have a refactoring option to convert an unscoped enumeration to a C++11 scoped enumeration, including all its referred enumerators.

As this is something that is done quite frequently in our code base, it would be a handy feature saving us from the tedious task to hunt down all referred enumerators and add their scope manually. A naive search-and-replace is too error prone.

enum Color { red, green, blue };
Color col = red;
switch(col)
{
    case red  : std::cout << "red\n";   break;
    case green: std::cout << "green\n"; break;
    case blue : std::cout << "blue\n";  break;
}

After refactoring becomes:
enum class Color { red, green, blue };
Color col = Color::red;
switch(col)
{
    case Color::red  : std::cout << "red\n";   break;
    case Color::green: std::cout << "green\n"; break;
    case Color::blue : std::cout << "blue\n";  break;
}

feline
Whole Tomato Software

United Kingdom
19014 Posts

Posted - Mar 01 2018 :  07:46:04 AM  Show Profile  Reply with Quote
We are considering adding a refactoring to convert a normal enum to a strong enum class, which will also update all of the enum item instances like this:

case=93116

For now, if you know which functions the enum items are being used in, you may find VA's Smart Select commands helpful, since this will let you quickly and easily select the entire function body, so you can do a search and replace just on the selected text, keeping the scope limited and thus more accurate:

https://support.wholetomato.com/default.asp?W560

zen is the art of being at one with the two'ness
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Dec 20 2019 :  2:24:24 PM  Show Profile  Reply with Quote
case=93116 is implemented in build 2358
https://support.wholetomato.com/default.asp?W404
http://builds.wholetomato.com/binaries/VA_X_Setup2358_0.exe
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000