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
 Inheritance by copy and paste
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Holi
New Member

Switzerland
3 Posts

Posted - Aug 30 2007 :  12:21:32 PM  Show Profile  Reply with Quote
Hi

I often thought that it would be so nice to be able to copy methods from one class to another and having the scope adapted to the new class automatically.

Example:

CMyBaseClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyBaseClass");
  // Comment related to CMyBaseClass
}

copy/paste in the new class (derived or not, shouldn't matter) automatically pastes the following code:

CMyDerivedClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyDerivedClass");
  // Comment related to CMyDerivedClass
}

or

CMyNewBetterClass::AnyVirtualMehtod()
{
  TRACE("Trace related to CMyNewBetterClass");
  // Comment related to CMyNewBetterClass
}

I guess this wouldn't be too much of a problem, as I think the parsed information should already provide data like this.

feline
Whole Tomato Software

United Kingdom
19019 Posts

Posted - Aug 30 2007 :  2:12:56 PM  Show Profile  Reply with Quote
We are considering a related idea. The idea is to sit in a derived class and ask VA to implement the virtual functions from the base class that you select:

case=1505

I don't really follow your example. To add or change the class name before the function name VA would have to know which class you were pasting the function into. But to do that you need to paste the function declaration, or inline implementation, into the class declaration. If the code is in the class declaration then you don't need to add the class name.

Once you have copy / pasted the declaration into the derived class you can simply use VA's Create Implementation refactoring on it.

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

sl@sh
Tomato Guru

Switzerland
204 Posts

Posted - Aug 31 2007 :  04:21:52 AM  Show Profile  Reply with Quote
Depending on what you do or want, replacing a class name within a TRACE, comment, or any command inside a function may not be correct, even if you move that function to a different class!

I am under the impression what you really want is some kind of intelligent cut&paste that does the hard work (adapting to the new context) for you. Unfortunately anything you might consider a logical adaption for the kind of code you are looking at might be unexpected for other people - and vice versa.

I do not think that it would make sense to make a tool 'guess' at what you want to be adapted and how - there are a million and one possible behaviours, and I guarantee that whatever you define as 'default' will make some people somewhere cry out 'foul!'.

In a situation like this, what I usually do, is use find/replace or better yet, 'Refactor Rename' to replace whatever I need replaced in a controlled way, then move the function. (or first move, depending on how much I expect the old or the new class's context to get in the way). When using Refactor Rename it is often helpful to first erase the 'MyClass::' bit from the function to avoid replacements within other functions of the class.

Edited by - sl@sh on Aug 31 2007 04:28:50 AM
Go to Top of Page

support
Whole Tomato Software

5566 Posts

Posted - Jan 24 2011 :  4:04:38 PM  Show Profile  Reply with Quote
case=1505 is implemented in build 1840

Whole Tomato Software, Inc.
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