Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Add include of underlying type

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
sitnduck Posted - Oct 27 2023 : 07:32:56 AM
I have to say I love "add include", I use it all the time. It's probably one of my most often-used shortcuts.

However, something that happens almost nearly equally, is that I am using a pointer object whose type is not defined, e.g.:

pObject->pMyTool->Use();

Often times, pMyTool by itself would be fine, having its type forward-declared in the .h (e.g. class Tool;).

HOWEVER the issue is that the "Tool" class itself needs to be included now that I am using "Use()".

So what I end up doing, and I do this quite often, is to write a throwaway line of code, such as "Tool dummy;", then use visual assist "Add include" on the "Tool" word, so the #include statement is generated at the top of the file, then I erase the throwaway line.

It would be really nice to have a shortcut to "Add include of underlying type", so that it would be able to use its Parsed knowledge of the underlying type of the variable and do that inclusion.

I hope that made sense!:)

1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Oct 31 2023 : 08:53:13 AM
I think this makes sense, so I have created a new, default C++ console, just to get a clear test case for this. I have set up the following three header files:

holdingObject.h has the "object" class you are talking about:

class TriangleObject;
class SquareObject;
	
class HoldingObject
{
public:
	TriangleObject *pTriangle;
	SquareObject *pSquare;
};

which forward declares the used pointer types. Then I have the two stored types:

squareObject.h

class SquareObject
{
public:
	int GetSquareColour() { return 1; }
};


triangleObject.h

class TriangleObject
{
public:
	int GetTriangleColour() { return 1; }
};


then I have the main file where I use this deeply complex code

#include "holdingObject.h"
    
int main()
{
    HoldingObject *pObject = new HoldingObject();
    pObject->pSquare->GetSquareColour(); // line that breaks compiling

    std::cout << "Hello World!\n";
}


as it stands, this code does NOT compile, since I have only included the holding object header file. If I comment out the problem line the code compiles quite happily. If I place the keyboard caret into "pSquare" on this line, Add Include is NOT offered, since the required header file is already included. If I place the caret into "GetSquareColour" then Add Include IS offered, and is offering to add:

#include "squareObject.h"

which seems to be what you are asking for.

I have tested this using VS2022 and VA 2502.0. Have I understood what you are describing correctly? Or have I not followed properly?

It could be my test case is to simple, but if so, what strangeness are you performing?

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