Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 switch expansion

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Mordachai Posted - Jan 18 2017 : 11:08:02 AM
Not sure if this is VA or MSVC++?

But, if I type 'switch' - then hit enter, it expands to a full switch statement:

switch (switch_on)
{
default:
break;
}

With "switch_on" highlighted, and if I type a symbol there, hit enter, then the switch is updated to reflect that enumeration's possible values.

Nice!!! Love this feature!

---

However (you knew it was coming)... if the symbol I type for 'switch_on' isn't trivial, then I don't get the expansion.

It's kind of ridiculous - if I do something like:

switch (myptr->GetSubType())
{
default:
break;
}

It fails. :(

If I instead take an extra moment to do:


auto x = myptr->GetSubType();
switch (x)
{
case SubType1:
case SubType2:
case SubType3:
case SubType4:
default:
break;
}

So, just by forcing the type information out to the current context, I get the snazzy best-case scenario.

But if I leave it even one layer indirected, then I get the dumb worst-case scenario. :'(

REQUEST:

If you can resolve:

auto x = 'thing-i-typed'

Then you can resolve it in the switch (switch_on) context!!!

Please!!! :D
2   L A T E S T    R E P L I E S    (Newest First)
Mordachai Posted - Jan 19 2017 : 2:32:55 PM
cool! Thanks accord :D
accord Posted - Jan 18 2017 : 3:51:00 PM
It's a Visual Studio feature, and I'm well aware of the limitations of this feature. This is one of the reasons why I was excited to work on a new refactoring feature for VA which is smarter in inferring the type and also capable of adding the missing statements in case the switch has already some items and you add a few new enum items afterwards:
https://docs.wholetomato.com/default.asp?W644

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000