Author |
Topic |
|
jlbooth318
Junior Member
17 Posts |
Posted - Sep 09 2008 : 09:42:10 AM
|
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 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 |
|
|
jlbooth318
Junior Member
17 Posts |
Posted - Sep 10 2008 : 10:29:14 AM
|
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...
|
|
|
feline
Whole Tomato Software
United Kingdom
19025 Posts |
Posted - Sep 11 2008 : 11:30:32 AM
|
*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 |
|
|
jlbooth318
Junior Member
17 Posts |
Posted - Sep 11 2008 : 1:06:37 PM
|
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. |
|
|
feline
Whole Tomato Software
United Kingdom
19025 Posts |
Posted - Sep 17 2008 : 7:26:20 PM
|
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 |
|
|
jlbooth318
Junior Member
17 Posts |
Posted - Sep 18 2008 : 08:34:39 AM
|
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. |
|
|
feline
Whole Tomato Software
United Kingdom
19025 Posts |
Posted - Sep 18 2008 : 12:36:48 PM
|
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 |
|
|
jlbooth318
Junior Member
17 Posts |
Posted - Sep 19 2008 : 09:02:28 AM
|
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! |
|
|
support
Whole Tomato Software
5566 Posts |
Posted - Dec 01 2008 : 07:26:50 AM
|
case=19512 is implemented in build 1707 |
|
|
|
Topic |
|