nvim-treesitter-cpp-tools
nvim-treesitter-cpp-tools copied to clipboard
Generate Switch from Enum (Feature Request)
Hello,
I've just found this plugin, which looks very interesting.
A thing I have to do sometimes is create switch statements for enum-types, mapping out every single element. So I'd propose a feature request, to generate switch statements from enum definitions.
For example from
enum Seasons {
SPRING, SUMMER, FALL, WINTER
};
Generate:
Seasons s = // ...
switch ( s ) {
case SPRING:
break;
case SUMMER:
break;
case FALL:
break;
case WINTER:
break;
}
While we're at it, a separate function to generate a code to convert the enum from String and to String would be swell as well. E.g.
std::string txt = // ...
if ( txt == "WINTER" ) {
return WINTER;
} else if ( ...
and
Seasons s = // ...
switch ( s ) {
case SPRING:
return "SPRING";
case ...
This is just a feature request. Thank you for your work, even if you don't find this feature interesting enough the implement.
Kind Regards, snaums
Hi, that sounds like a useful feature to have. Thanks for the suggestion.