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 for introduce variable...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dango
Junior Member

20 Posts

Posted - Jan 15 2008 :  6:10:12 PM  Show Profile  Reply with Quote
When I'm creating new code I often type the code before adding new member variables to the class.

Could you add a refactoring when you notice a lhs name is not recognized to introduce a new variable/new field/new member variable?

Thanks,
D

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 17 2008 :  2:48:01 PM  Show Profile  Reply with Quote
Are you talking about local variables that are being underlined as mistyped symbols?

So long as you are in a class member function triggering a variation of VA's "Add member" dialog to add the variable to the current class sounds reasonable. It could pick up the unknown variable, but it would not have any idea of the type. You would need to type (or copy / paste) this into the dialog without any help from VA - no suggestions.

Is this what you are thinking of?

It seems quite reasonable, I am just a little concerned that people will be unhappy that VA has not attempted to infer the type of the variable. You can make an argument for doing this, but I can just see to many edge cases, involving pointer types and implicit casts for this to be wise.

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 - Jan 21 2008 :  04:22:38 AM  Show Profile  Reply with Quote
Talking about new lhs variables, the appropriate type could be derived from the right hand side expression. Eclipse does something along these lines, allowing to correct a type definition on an initialisation line. E. g. in
double bar = 2.5;
int foo = 3*bar;
, the second line would be automatically transformed into
double foo = 3*bar;
by invoking the right shortcut.

This becomes a lot more helpful when invoking functions that return objects of templated classes, such as
std::list<MyClass>::const_iterator
, saving the time to look up the exact return type and actually typing it out!

Edited by - sl@sh on Jan 21 2008 04:27:05 AM
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
18943 Posts

Posted - Jan 21 2008 :  4:08:18 PM  Show Profile  Reply with Quote
I like the idea, but my immediate reaction is that we are going to run into a pile of edge cases. Just taking something very simple, if you have the code:

int nFoo = 2;
test1 = nFoo * 1.0;
test2 = nFoo * 2;


I know what I probably mean, but this is opening the whole issue of implicit casts. It really depends on how clever people want the feature to be.

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