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
 Technical Support
 C++: Intellisense trouble w/ inner class from base
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dave_lf
Junior Member

15 Posts

Posted - Sep 10 2014 :  08:29:30 AM  Show Profile  Reply with Quote
I use a lot of dependency injection in my code. I also like to use interface-based programming. Between the two, I often end up with constructs that look like this (stripped down to its essence):

// MyClass.h

class MyClass
{
public:
   struct Parameters
   {
      int v1;
      int v2;
      // etc. These are really pointers to dependencies,
      // but int is sufficient to trigger the problem 
   };

   static MyClass* Create(const Parameters& p);
	
   virtual ~MyClass();

protected:
   MyClass();
};



// MyClass.cpp

#include "stdafx.h"
#include "MyClass.h"

class MyClassImpl : public MyClass
{
public:
   MyClassImpl(const Parameters& parameters)
   {
      // ...
   }

   // ...
};

MyClass* MyClass::Create(const Parameters& p)
{
   return new MyClassImpl(p);
}

MyClass::MyClass()
{
}

MyClass::~MyClass()
{
}
Any time I follow this pattern in my project, I am completely unable to get intellisense for Parameters anywhere inside the derived MyClassImpl. However, I do get intellisense inside the base MyClass. What's more, if I copy/paste the exact same code into a new project, it will work in both places. So something else in my project (maybe in stdafx?) must be a key ingredient, but I don't have any idea what. I have no (consistent) trouble with intellisense under any other circumstances.

Any ideas?

Followup: If I qualify Parameters with MyClass::, the problem does not occur. And crucially, the same is true if I rename the struct to anything other than Parameters. I'm guessing something in the mass of files included in the main project's stdafx must use that same identifier for something else.

Edited by - dave_lf on Sep 10 2014 09:09:10 AM

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Sep 11 2014 :  6:00:21 PM  Show Profile  Reply with Quote
quote:
Any time I follow this pattern in my project, I am completely unable to get intellisense for Parameters anywhere inside the derived MyClassImpl.

1. So, for example, if you type "parameters." inside the constructor of MyClassImpl, you don't get v1 and v2 in a listbox when you try this in your "real" project, but you do get them when you try the same in a clean new project?



Can you please open the Find Symbol dialog (Shift+Alt+S or VASSISTX -> Find Symbol...) and type the word "Parameters"? (without quotes)

2. Do you get another definition or just yours?
3. Can you please untick "Show only symbols defined in current solution"? Does it make any difference?

4. Do you use any "complex" macros in your project? What I mean by that macros that call other macros or macros that creates code: either members (e.g. setters and getters for a variable) or classes, or basically anything else.

It may cause problems if Visual Assist doesn't understand some macros fully, and usually there are ways to solve these situations if they occur.
Go to Top of Page

dave_lf
Junior Member

15 Posts

Posted - Sep 24 2014 :  12:36:57 PM  Show Profile  Reply with Quote
Sorry for the delay.

1. Yes, that is correct.
2. I get tons of hits. 10,273 of them, in fact. But it seems to be including anything that contains the (case-insensitive) text "Parameters" in it, including symbols like AFX_SOCKETPARAMETERS_H__8D1C4D19_3E62_4049_81B8_BA3C6046DF0A__INCLUDED_
3. That reduces the number of hits to 8,525
4. Yes. This is a MFC application, and it defines several such macros all by itself. Boost adds more. And I wouldn't be surprised to find some of our own buried somewhere in the bowels of the project.

Edited by - dave_lf on Sep 24 2014 12:44:07 PM
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Sep 24 2014 :  5:47:36 PM  Show Profile  Reply with Quote
Thank you for the addition info. I was able to reproduce the problem and put in a bug report for this:

case=85237

Which Visual Studio version are you using?
Enabling the below option should help provided you didn't disable Intellisense:
VA Options -> Listboxes -> Get content from default Intellisense

Edited by - accord on Sep 24 2014 5:47:51 PM
Go to Top of Page

dave_lf
Junior Member

15 Posts

Posted - Sep 29 2014 :  09:55:52 AM  Show Profile  Reply with Quote
Thanks, accord; I'm using VS2012. I seem to recall that option causing me some trouble in the past (I think due to the default VS intellisense not being very good), but enabling it does indeed allow me to get intellisense for objects named "Parameters". And it is fine as a workaround.
Go to Top of Page

sean
Whole Tomato Software

USA
2817 Posts

Posted - Feb 13 2015 :  8:02:26 PM  Show Profile  Reply with Quote
case=85237 is fixed in build 2059
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