EnumSwitch.refscript
This page describes the EnumSwitch RefactorScript shipped with VisualGDB.
Overview
This is a very basic script generating a "switch" statement for all values of an enum.
In order to run this script, first select an enum in Code Explorer -> Outline.
Script
[Main]
generator GenerateEnumSwitch(Enum enum)
{
>switch()
>{
foreach(val in enum.Values)
{
>case $val.ShortName:
> //TODO: handle this
> break;
}
>}
}
Sample Input
enum TestEnum
{
Value1,
Value2,
Value3,
};
{
Value1,
Value2,
Value3,
};
Sample Output
switch()
{
case Value1:
//TODO: handle this
break;
case Value2:
//TODO: handle this
break;
case Value3:
//TODO: handle this
break;
}
A detailed reference on RefactorScript syntax and data model is available here.{
case Value1:
//TODO: handle this
break;
case Value2:
//TODO: handle this
break;
case Value3:
//TODO: handle this
break;
}
See this page for a full list of RefactorScripts shipped with VisualGDB.