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
 switch expansion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Mordachai
Tomato Guru

USA
224 Posts

Posted - Jan 18 2017 :  11:08:02 AM  Show Profile  Reply with Quote
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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jan 18 2017 :  3:51:00 PM  Show Profile  Reply with Quote
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
Go to Top of Page

Mordachai
Tomato Guru

USA
224 Posts

Posted - Jan 19 2017 :  2:32:55 PM  Show Profile  Reply with Quote
cool! Thanks accord :D
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