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
 Intellisense not working for macro generated enums
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ben_t48
New Member

4 Posts

Posted - Apr 13 2012 :  7:19:28 PM  Show Profile  Reply with Quote
In our code-base, we often use a macro to generate an enum and a table of data that can be indexed using the generated enum (example given below). The intellisense in Visual Assist is unable to help auto-complete any of the enum members that were added using the macro; for the example below only SubLevelState_Count will show up in the autocomplete list. Would it be possible for this to be added to a feature/bug list somewhere?

Ben

Example:

#define SUBLEVELSTATES \ SUBLEVELSTATE(Idle, 2.0f ) \ SUBLEVELSTATE(WaitingForBundleLoad, 5.0f ) \ SUBLEVELSTATE(BundleLoadCompleteDelay, 2.0f ) \ SUBLEVELSTATE(BundleLoadComplete, 2.0f ) \ SUBLEVELSTATE(WaitingForBlueprintBundles, 2.0f ) \ SUBLEVELSTATE(EntitiesCreated, 2.0f ) \ SUBLEVELSTATE(WaitingForRefCountDecrement, 8.0f ) \ SUBLEVELSTATE(WaitingForBundleUnload, 2.0f ) \ SUBLEVELSTATE(BundleUnloadComplete, 2.0f ) \ SUBLEVELSTATE(ImpromptuLoad, 2.0f ) \ SUBLEVELSTATE(ImpromptuUnload, 2.0f ) \ SUBLEVELSTATE(Clear, 0.0f ) \
enum SubLevelState
{
#define SUBLEVELSTATE( name, level_mult ) SubLevelState_##name,
SUBLEVELSTATES
#undef SUBLEVELSTATE
SubLevelState_Count
};

struct SubLevelStateInfo
{
const char *Name;
float LevelMuliplier;
};

SubLevelStateInfo g_SubLevelStateInfo[] =
{
#define SUBLEVELSTATE( name, level_mult ) { #name, level_mult },
SUBLEVELSTATES
#undef SUBLEVELSTATE
};

const char *displayName = g_SubLevelStateInfo[ SubLevelState_Clear ].Name;

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Apr 17 2012 :  5:38:13 PM  Show Profile  Reply with Quote
The main problem here is that VA's parser has problems with ## in a macro, making a new name:

case=729

This is a known problem, but its a hard one, since we don't get to run the code through a pre-processor before trying to make sense of it.

Does turning on:

VA Options -> Advanced -> Listboxes -> Get content from default Intellisense

make a difference? It is making a difference for me, in VS2010.

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

ben_t48
New Member

4 Posts

Posted - Apr 19 2012 :  4:33:02 PM  Show Profile  Reply with Quote
Sadly that is not helping for our project.

I have
VA Options -> Advanced -> Listboxes -> Get content from default Intellisense
option enabled, but I have
Tools -> Options... -> Text Editor -> C/C++ -> Advanced -> (Intellisense) Disable Auto Updating
set to true because our project is large (over <100 projects and <10000 files) and the default intellisense really drags down performance of the machine.

Ben
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18749 Posts

Posted - Apr 19 2012 :  7:27:41 PM  Show Profile  Reply with Quote
I assume you are using VS2010, from this IDE option. If so you might want to have a look at this page, for some possible advice on limiting the CPU impact of default intellisense parsing:

http://blogs.msdn.com/b/vcblog/archive/2010/03/09/intellisense-browsing-options-in-vc-2010.aspx

Do you have many macros like this, or just a few? If this is only used to generate a fairly small number of problem enums we might be able to work around this. But if this is used to generate many different enums then any workaround is unlikely to scale well.

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

ben_t48
New Member

4 Posts

Posted - Apr 25 2012 :  2:05:50 PM  Show Profile  Reply with Quote
We generally only use this type of enum generation when we want to build a table of data that will use the enum to do a lookup. That being said we probably do it 30-40 times in our code base.

Ben
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Apr 25 2012 :  7:58:51 PM  Show Profile  Reply with Quote
Can you please try enabling recursive macro parsing with "NoDepthLimit"?

http://docs.wholetomato.com?W363

I've just tried and it is working for me:


The small tomatoes behind the icons in the listbox indicates that the result is coming from VA rather than Intellisense, so you don't need to re-enable it with this method.

I see some things in your source snippet that VA don't usually like, e.g. the #undef but so far so good. Hopefully it'll work with your "real" project as well...

Edited by - accord on Apr 25 2012 8:31:43 PM
Go to Top of Page

ben_t48
New Member

4 Posts

Posted - Apr 26 2012 :  5:21:04 PM  Show Profile  Reply with Quote
The undef is require for our usage because we need to redefine what SUBLEVELSTATE means for the various expansions of SUBLEVELSTATES.

The NoDepthLimit change makes it work. Thanks! I will create a registry patch for everyone on our team.

Ben
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