Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
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  

Junior Member

23 Posts

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

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;
    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;
    case Color::red  : std::cout << "red\n";   break;
    case Color::green: std::cout << "green\n"; break;
    case Color::blue : std::cout << "blue\n";  break;

Whole Tomato Software

United Kingdom
18083 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:


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:


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

Whole Tomato Software

2817 Posts

Posted - Dec 20 2019 :  2:24:24 PM  Show Profile  Reply with Quote
case=93116 is implemented in build 2358
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2021 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000