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: extract class to file(s)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

borgman
New Member

8 Posts

Posted - Jul 29 2008 :  6:01:20 PM  Show Profile  Reply with Quote
there is a lot of tedious, error-prone grunt work to pulling a class out of one file, creating an appropriately named file for the extracted class, pulling over appropriate includes, Header, .cpp, namespacing ... ugh!!!

It seems like you guys already have all the information to make this refactoring easy.

What are the chances?

feline
Whole Tomato Software

United Kingdom
19023 Posts

Posted - Jul 30 2008 :  08:40:15 AM  Show Profile  Reply with Quote
Automatically adding files to the solution is not going to happen. There are several reasons, including not knowing which directory to use, which project to use, and source control for this.

Have you tried using VA Outline to cut the items you want to move from the original file, so you can simply paste them into the target file?

This is not quite the same, but it should help.

Without a better understanding of what you are trying to do I am wary of saying anything more. Normally I create classes in individual files to start with, so I don't normally have to move them to a new file.

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

Krakken
Ketchup Master

Australia
63 Posts

Posted - Jul 31 2008 :  7:48:00 PM  Show Profile  Reply with Quote
borgman, you can do most of the grunt work in a customised way by using Visual Studio macros. I used to have one that would prompt me for the name of the class, create two new files with the appropriate name and fill the files out with a pre-defined template for me. You can load these templates from file and replace certain keywords or just have the macro generate it. All I had to do then was to click "Save" and I would be prompted by the IDE asking where to save the file. Saved me a lot of time, I should probably re-make it TBH.

As for VAX, this could be done in the same way and as snippets improve their variable database, could be customised quite nicely. There is no need for VAX to save the file, that can be a quick, manual process.
Go to Top of Page

GennadiyKorol
Ketchup Master

Israel
54 Posts

Posted - Aug 01 2008 :  1:56:21 PM  Show Profile  Reply with Quote
Krakken:

I was about to start writing the exactly the same macro for adding new class files to the project. If it's not too NDA'ish, could you please share your version?

Thanks!

Correctness might be a theoretical concept but incorrectness has practical implications.
Go to Top of Page

Krakken
Ketchup Master

Australia
63 Posts

Posted - Aug 04 2008 :  04:00:46 AM  Show Profile  Reply with Quote
Unfortunately I lost that macro a while back. To create the new files there's:

DTE.ItemOperations.NewFile("Visual C++\\Header File (.h)")
DTE.ItemOperations.NewFile("Visual C++\\C++ File (.cpp)")

The rest is standard stuff. If you get stuck with any of the commands I always just CTRL+SHIFT+R (record macro) perform the action then CTRL+SHIFT+R again (stop recording) and check the generated code in the temporary macro.

File loading will have to be written manually in the VBScript. Good luck! :)
Go to Top of Page

borgman
New Member

8 Posts

Posted - Aug 04 2008 :  10:51:34 AM  Show Profile  Reply with Quote
Yah, I've got some class templates similar to what you've suggested. The Unit Testing template is especially popular.

We've got a lot of legacy code where pulling out classes adds a lot of tedium.

Thanks all.
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