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
 want a $PreviousClassName$
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mnicolella
Junior Member

14 Posts

Posted - Aug 22 2013 :  5:08:32 PM  Show Profile  Reply with Quote
I'd like to refer to the most-recent class name definition, so I can auto-generate free functions just below the class definition.

For example:

struct Foo
{
};

void Serialize( Serializer& s, Foo& obj );

I'd like to make a snippet to generate that Serialize() signature, like this:
void Serialize( Serializer& s, $PreviousClassName$& obj );

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 23 2013 :  9:43:41 PM  Show Profile  Reply with Quote
Is this something you often do?

Are you aware of the $clipboard$ token that you can use in VA Snippets? You could copy the class name, and then use this token, which would give you more flexibility when generating these function signatures.

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

mnicolella
Junior Member

14 Posts

Posted - Aug 26 2013 :  1:08:57 PM  Show Profile  Reply with Quote
Yes, I'm aware that I can do this with $clipboard$, and that's more flexible, but it's more clicks and keypresses - if I had $PrevClassName$ it would make this use case a lot slicker
Go to Top of Page

jay.carlton
Ketchup Master

USA
65 Posts

Posted - Aug 26 2013 :  2:18:47 PM  Show Profile  Reply with Quote
Hi,

I'm interested in a snippet or snippets to move methods
* from an existing class to a nested class within it
* from an existing class to a free (static) function
* from a free function into a separate class

So maybe a more generic version of what mnicolella wants would be some thing like $targetClass$?

Either way, you'd be introducing a time-dependence, or an assignment that outlives an individual snippet expansion.

@mnicolella, would it be perhaps simpler to include the free functions associated with all your structs in a snippet that also gives you the struct declaration? That would remove some of the context dependence I'd think:


struct $PrevClassName$
{
};

void Serialize( Serializer& s, $PrevClassName$& obj );


Or do you mean previous as in, "the most recently defined class name in this file" as opposed to "the class name most recently used by VA X"?

HTH,

Jay
Go to Top of Page

mnicolella
Junior Member

14 Posts

Posted - Aug 26 2013 :  3:23:22 PM  Show Profile  Reply with Quote
I meant "the most recently defined class name in this file"

Including the struct definition is fine, but doesn't help when retrofitting existing code
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 26 2013 :  3:46:46 PM  Show Profile  Reply with Quote
Jay, you can do simple moves like this via VA Outline, by selecting and cutting the functions or classes you want to move, and then simply pasting them into a different file. Or via drag and drop if you are just moving them around in the current file.

The problem is going to be updating all of the calls to the moved methods, which VA Snippets are not going to be able to help you with. We don't currently have a refactoring command to do this, but we are considering adding features in this area.

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

Edited by - feline on Aug 26 2013 3:47:18 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18947 Posts

Posted - Aug 26 2013 :  4:25:32 PM  Show Profile  Reply with Quote
mnicolella this makes sense, and you have made a good case for this. I have put in a feature request to see what our developers make of this:

case=76425

As a temporary work around, the following VA Snippet works:

void Serialize( Serializer& s, $ClassName=$clipboard$ $& obj );

This will prompt you for the class name to use, but it will pre-fill the prompt dialog with the content of the clipboard. So you could type in the class name if not already in the clipboard history, and then copy it to be used on the next function. I know its not the same, but it might help a little bit.

zen is the art of being at one with the two'ness
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