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
 Refactor suggestion -- change base class
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jlbooth318
Junior Member

17 Posts

Posted - Sep 09 2008 :  09:42:10 AM  Show Profile  Reply with Quote
It would be nice to see when hovering over a class name in a header file, an option to change the base class name for the selected class. I realize this could be fairly complicated if the class has more than one base class or is derived from a templated class.

Visual Assist could be smart enough to only show the change base option only if the selected class is derived from a single class. Visual Assist could do the rename operation in both the header file and the cpp file.

feline
Whole Tomato Software

United Kingdom
19025 Posts

Posted - Sep 10 2008 :  10:04:54 AM  Show Profile  Reply with Quote
Show VA View, then place keyboard focus back into the editor, and now hover the mouse over the derived class name.

If you right click on the base class in VA View you can select Rename from the context menu.

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

jlbooth318
Junior Member

17 Posts

Posted - Sep 10 2008 :  10:29:14 AM  Show Profile  Reply with Quote
That works, but...not quite what I had in mind. Consider:

class CLoginDlg : public CDialog
{
....
}

Suppose I *only* want to change the base class for CLoginDlg to something other than CDialog. The rename option will search for all instances of CDialog in every file in my project when I only want to change the base class in the CLoginDlg.h file and the CLoginDlg.cpp file.

This suggestion kind of ties in with my previous suggestion to reorganize the items in the rename dialog by project.

Of course there's always the raggedy old IDE "search and replace in current document" option...

Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19025 Posts

Posted - Sep 11 2008 :  11:30:32 AM  Show Profile  Reply with Quote
*ah* I see what you are asking for now. My first reaction is that you only need to change the class declaration and the constructors, since these are the only places where the parent class is referenced. In fast the constructors may not even mention the parent class. So 3 or 4 places on average.

As soon as you go beyond this and look at inherited members then VA cannot do this for you anyway, since you need to decide what the code has to become.

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

jlbooth318
Junior Member

17 Posts

Posted - Sep 11 2008 :  1:06:37 PM  Show Profile  Reply with Quote
In my opinion this is as simple as a "replace references" operation restricted to the .h file and the .cpp file for the selected class. The base class can be referenced in the .cpp file many times if you have quite a few overloaded methods where the overloaded method implentations call the base class methods. In addition, the base class is often referenced in many MFC macros (e.g. BEGIN_MESSAGE_MAP, IMPLEMENT_DYNCREATE, etc).

I don't quite see why VAX would need to look at inherited members when changing the base class.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19025 Posts

Posted - Sep 17 2008 :  7:26:20 PM  Show Profile  Reply with Quote
If it is this simple then why not simply run an IDE find and replace in both files? You have this option now, without waiting for any changes to VA

Or am I missing something obvious here?

My reference to inherited members was about changing the base class from ClassA to ClassB, which is likely to require quite a few other changes to be made to your code.

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

jlbooth318
Junior Member

17 Posts

Posted - Sep 18 2008 :  08:34:39 AM  Show Profile  Reply with Quote
It's all about the refactoring features that VAX brings to the Visual Studio IDE. Changing the base class is a refactoring operation and a fairly common one especially if you're working to integrate 3rd party libraries (e.g. Prof-UIS) into an existing project.

If this is totally out of the question with VAX, then I'd be just as happy with the grouping of references by project in the VAX rename dialog. At least that makes it easy to see all the references to the base class name at once and to pick and choose whether to make the changes in the .cpp and .h files.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19025 Posts

Posted - Sep 18 2008 :  12:36:48 PM  Show Profile  Reply with Quote
I think we are talking about different things here.

Let us assume you have the following code:

class myDerivedClass :: public std::string { /* ... */ }

If you now change "std::string" into CString then the code inside myDerivedClass is likely to break.

My concern here is that if VA offers a command to change the base class people are going to ask for VA to try and resolve the problems this change causes. This is not something that VA can really do, since VA is not going to understand what you are trying to achieve.

We are looking to add an option to group files in the rename dialog by project:

case=19512

which will hopefully show up in the next few builds. This should help when it arrives

zen is the art of being at one with the two'ness

Edited by - feline on Sep 18 2008 12:37:16 PM
Go to Top of Page

jlbooth318
Junior Member

17 Posts

Posted - Sep 19 2008 :  09:02:28 AM  Show Profile  Reply with Quote
I see what you mean. I guess I was narrowly focused to using the feature for MFC classes. Of course, even the rename option has the potential for breaking code.

Thank you for quick support and a great product!
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Dec 01 2008 :  07:26:50 AM  Show Profile  Reply with Quote
case=19512 is implemented in build 1707
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