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
 Refactoring function name into .h and .cpp
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Vsk
New Member

3 Posts

Posted - Feb 18 2008 :  1:26:01 PM  Show Profile  Reply with Quote
Hi, Althoug visual assist is quite good, it still lacks of some basic functions or at least I don't know how to use it .
Well, what I want is a behavior like Eclipse with java, I explain mysefl:

Supposed the following code:

if (something){

if (name_Object_fromClass->operationX(z,y)){
somethingelse.
}

}


Well supposues that I already have the class form "name_object_fromClass" declared but this one doesn't have still the "operationX(tipoZ z, tipoY y)" function.
Well I would like that VA make me the posibilitie of adding this operation on the .h and .cpp correctly.
What it should do is quite simple, I dono't know why now is not doing it:
1)Look for the file that the class fromo this object is declared.
2)add the function to the .h correctly settin the correct tipe for z e y (in this example) parameters and return tipe.
3) the same in the .cpp correctly.

Anyonw know how can I perform this.
I have tried add in it in edit text but I don't know which means every paramter provided and thus I can not creat it.

Thanks-.

Edited by - Vsk on Feb 18 2008 1:27:04 PM

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 18 2008 :  2:58:26 PM  Show Profile  Reply with Quote
Wow, I have seen this yesterday at http://www.jetbrains.com/resharper/features/code_generation.html
See "Create From Usage"
It is pretty neat :) and I think it can be done by VAX's parser, because VAX know the type of every variable.
For example: compare VAX and Refactor Pro's "Extract Method". VAX is simply amazing: recognises the types correctly, Refactor pro is awfully misunderstand a lot of types (only some very basic (like int and float) types are recognised by the latest 3.0.5 build...) (C++)

I think you should use your really powerfull "type engine" to create even more refactoring operations!

Edited by - accord on Feb 18 2008 3:08:37 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 19 2008 :  09:42:39 AM  Show Profile  Reply with Quote
We do a simplified version of this. Consider this C++ code:


class testThingsGenerally
{
private:
	int m_nSize;
};

testThingsGenerally::newMember(int nFoo, int nBar)	{ }

You can now run the command Create Declaration on the function "newMember" and VA will add the declaration to the class.

This reminds me of the recent discussions over creating variables. The idea is very similar, and I have the same concern. VA should get it right 95% of the time, or more. Is this often enough? I am starting to think it is.

It turns out someone has already put in this feature request:

case=2451

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

Vsk
New Member

3 Posts

Posted - Feb 19 2008 :  10:15:32 AM  Show Profile  Reply with Quote
Thanks for your quick response.
Painfully I don't quite undertand your suggestion.
Feline the one that you are indicating is the one almost that I want to do. But not in this way.
I explain again:
If I have alreday the class "A" created. and I have in some code and object "a" instance of "A".
If I apply a->operation(x,y), I want that VA. add the operation to "A" with the correct operators and returns. But that must be done in .h and .cpp.

I try to add a new refacto function with "edit autotext" But I dont' know where to find what every key simbol mean; I mean the simbols betwen $$.
What would it be the steps to acomplish this?
This are my specification from VA.
VA_X.dll file version 10.3.1559.0 built 2007.07.06
VAOpsWin.dll version 1.3.2.4
VATE.dll version 1.0.5.8
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 19 2008 :  12:35:15 PM  Show Profile  Reply with Quote
Currently we do not have the feature you are asking for. We are considering adding it, or something very close. This is case=2451

When editing Autotext, which have been renamed to Snippets, the $$ tokens are described here:

http://www.wholetomato.com/products/features/vasnippets.asp

Near the bottom of the page, the section called "Code"

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

Vsk
New Member

3 Posts

Posted - Feb 20 2008 :  10:59:28 AM  Show Profile  Reply with Quote
Oh thanks that is what I need.
But If I can implement this feature for myself using this simbols right?
The only part that I am unsure is about find the .cpp and .h that the class belong from. After that I think I would not have any problem.
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 20 2008 :  12:29:31 PM  Show Profile  Reply with Quote
I don't think you can, at least not directly. The information you want is not available inside a normal snippet. The Refactoring $$ words only work inside the Refactoring snippets:

Refactor Create Implementation
Refactor Encapsulate Field
Refactor Document Method
Refactor Extract Method

They do not work in other snippets, since VA does not have the context to understand them.

This FAQ entry explains how to easily swap between different snippets for a refactoring operation:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=7024

You might be able to get one of the refactoring commands, perhaps Document Method to generate useful code for you, since Document Method will give you details about the function parameters. However this is not going to work on a function call in the middle of an existing function.

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

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 20 2008 :  4:32:56 PM  Show Profile  Reply with Quote
So case=2451 is what jetbrains call "Create From Usage"?
Described here: http://www.jetbrains.com/resharper/features/code_generation.html

I have missed this feature several times. For example I would like to check something in a class:

void cVehicle::SomeFunction()
{
...
    if (GetUnitAI()->IsThisUnitCrazy|()) // '|' is the caret
...
}

Here I press the shortcut for "Create From Usage" (or choose from right-click menu) and

bool cUnitAI::IsThisUnitCrazy()
{
    |
}

...and it's declaration in the header can created by one moment. I think it can be usefull in everyday use.
Certainly GetUnitAI() returning with cUnitAI* in my example's context.

When you do this new feature VAX can find cUnitAI* class definition, paste the new function's declaration and then use "create implementation" feature which is already implemented very well

OK, figuring out the returning type can be hard if I want to use this from an expression, like in this example :) But I think it can be done.

Edited by - accord on Feb 20 2008 4:41:55 PM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18751 Posts

Posted - Feb 21 2008 :  08:19:15 AM  Show Profile  Reply with Quote
Yes, it should be the same concept / refactoring operation.

Looking at this example my feeling is that VA should show a dialog, similar to the dialog used for Change Signature, so you can make any edits to the suggested signature before accepting it. The return type could be "int", "void *", "char *", "long", there are quite a few reasonable choices.

bool is probably the best default for an if statement, but what about inside a while statement? A for loop?

There are always going to be a few odd edge cases, but VA should be able to suggest something reasonable most of the time.

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