Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 C++: Intellisense trouble w/ inner class from base

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
dave_lf Posted - Sep 10 2014 : 08:29:30 AM
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.
5   L A T E S T    R E P L I E S    (Newest First)
sean Posted - Feb 13 2015 : 8:02:26 PM
case=85237 is fixed in build 2059
dave_lf Posted - Sep 29 2014 : 09:55:52 AM
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.
accord Posted - Sep 24 2014 : 5:47:36 PM
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
dave_lf Posted - Sep 24 2014 : 12:36:57 PM
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.
accord Posted - Sep 11 2014 : 6:00:21 PM
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.

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