Author |
Topic |
|
Vsk
New Member
3 Posts |
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Feb 18 2008 : 2:58:26 PM
|
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 |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 19 2008 : 09:42:39 AM
|
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 |
|
|
Vsk
New Member
3 Posts |
Posted - Feb 19 2008 : 10:15:32 AM
|
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
|
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 19 2008 : 12:35:15 PM
|
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 |
|
|
Vsk
New Member
3 Posts |
Posted - Feb 20 2008 : 10:59:28 AM
|
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.
|
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 20 2008 : 12:29:31 PM
|
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 |
|
|
accord
Whole Tomato Software
United Kingdom
3287 Posts |
Posted - Feb 20 2008 : 4:32:56 PM
|
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 |
|
|
feline
Whole Tomato Software
United Kingdom
19020 Posts |
Posted - Feb 21 2008 : 08:19:15 AM
|
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 |
|
|
|
Topic |
|