Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Refactor for unknown symbol...

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
dango Posted - Dec 05 2006 : 08:37:24 AM
I frequently introduce a new variable in code before I declare it.

VAX cleverly notices it is unknown. Of course it doesn't know if its a mis-spelling or intentional.

Could you under these circumstances introduce a refactoring... "Create local variable" or if in a class member "Create member variable"

Thanks - DanGo
15   L A T E S T    R E P L I E S    (Newest First)
peterchen Posted - Dec 19 2006 : 7:35:37 PM
>> What happens when I go from the code: [...] to [...]

OK, I understand that, but I don't see how you can add some value in this situation: I have my cursor right at the position where I want to do the change, I can type [ctrl-left] "int " (maybe guessing the type is "int", but how??). It is a very local chage right at my cursor, I can do that myself, thank you ;)




>> Here the function call is inside the global function "foo()", so are you thinking the new function is automatically global, i.e. it has the same "scope" as foo(), or are you looking for something more clever? (...) by the same logic (...)
This seems reasonable.

I see one exception I commonly use: for

void CBar::foo2()
{
    int bar;
    Samba2(bar);
}


I might want to declare Samba() in the same .cpp as global static (i.e. not as a member). However, if you make it a member by default, you would add the following code to the CBar declaration:


void Samba(int foo)
{
}


I can easily select the three lines, hit ALT-O, and paste the method into the .cpp file. That's ok for me, but I can see people ask for a checkbox/combobox in the "signature" dialog.

I'd prefer the simpler signature dialog, so that simple approach would be fine for me.




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

I don't understand his request fully myself (rather, what I understand is a very complex refactoring step that seems very specific, but I'm not sure)

As I understand, what overlaps:

(1) When you create a member variable or member function: Do you want to make it a member of CBar (i.e. the class you are in), or a base class of CBar?

A separate refactoring step "move member to base/derived class" can do this and would be helpful anyway

(2) I have
someVar.Samba()

where Samba is the unknown symbol for which I start refactoring.

Assumig that someVar is known and of type CSomeVar, I would expect "Samba()" to be added to CSomeVar.




>> One possible problem with this is allowing the user to edit the signature of the new function. If the class name is included in the edit field then what happens if the user changes the class name? So the class name would have to be excluded, like Change Signature does.

That's fine. I don't think anything useful can be done (in a robust way) by specifying a class name.
feline Posted - Dec 19 2006 : 1:46:12 PM
finally starting to catch up

quote:
Originally posted by peterchen

How could Samba be a variable?


What happens when I go from the code:

void foo()
{
    int bar;
    Samba(bar);
}


to

void foo()
{
    int bar;
    int Samba(bar);
}


I guarantee it won't take long at all for someone to do this, and then ask / complain about it Never under estimate our users, they are very cunning programmers

Ignoring this for the moment, and thinking about functions, I am still trying to wrap my head around this feature request thread:

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

so I don't want to think to deeply about how these two treads might overlap just yet, but I have the feeling I need to be careful here.

Here the function call is inside the global function "foo()", so are you thinking the new function is automatically global, i.e. it has the same "scope" as foo(), or are you looking for something more clever?

A fairly simple approach here is:

void foo()
{
    int bar;
    Samba(bar);
}


the new function Samba() is global, since foo() is global. So by the same logic:

void CBar::foo2()
{
    int bar;
    Samba2(bar);
}


Samba2() will become a member function of CBar, since this is the scope of foo2().

One possible problem with this is allowing the user to edit the signature of the new function. If the class name is included in the edit field then what happens if the user changes the class name? So the class name would have to be excluded, like Change Signature does.

VA may be able to make some guesses about the parameter types, so long as the parameters being passed are known variables.
sean Posted - Dec 11 2006 : 9:22:19 PM
quote:
Originally posted by peterchen



try 
{ 
  while (user.ask())
    feline.sayNo(); 
} 
catch(FelineGivesUpException) 
{ 
  WT.ImplementFeature(); 
}




brilliant!
peterchen Posted - Dec 11 2006 : 1:35:14 PM
To clarify:

I just thought how "static" and "external" can be folded into one:

__Add global function__

- ask me for prototype (bonus: suggest parameter list (int bar) from the samba call. this will not always work)
- add method e.g. "void Samba(int bar) { ... }" to current/associated .cpp file.
- Keep cursor at Samba(bar) call OR make "Alt-Left" go back to this position.
- Make sure I can immediately use ALT-G on the Samba(bar) call to get to the Samba() implementation

To create a static funciton, I cansimply add "static" when you ask me for the prototype. For an extern funciton, I can use refactor.CreateDeclaration on the newly created function body


__Add Member function__
- ask me for prototype (bonus: suggest parameter list (int bar) from the samba call. this will not always work)
- add method e.g. "void Samba(int bar) { ... }" to the class declaration where foo is a member of
- best is probably to move to the cursor to the newly created function (decl+impl in the class decl)
- From this point I could do one of the following:
- Alt-CursorLeft to go back to the Samba(bar) call
- Refactor.MoveImplementationToSourceFile + 2xAlt-CursorLeft to go back to the Samba(bar) call
- Refactor.MoveToBaseClass (if you offer such a thing)

edit: This is just an idea how this feature would best fit with the current style of VAX (chaining few simple commands and all). Of course we can always haggle :)

peterchen Posted - Dec 11 2006 : 1:18:00 PM
What I expect:

Add static function
Add external function
Add member function (only if "foo" is actually a member method, e.g. foo::foo)

How could Samba be a variable?
It could be a functor or the instance of some class that overloads operator() - but that's a rare case (at least for me). I wouldn't mind if this isn't supported. Or am I missing something?

>> but when you start thinking about edge cases some feature requests get a little complex
yes, we should continue with the

try 
{ 
  while (user.ask())
    feline.sayNo(); 
} 
catch(FelineGivesUpException) 
{ 
  WT.ImplementFeature(); 
}

Otherwise VAX would quickly explode from bloat (exbloat?) ;)
feline Posted - Dec 11 2006 : 08:29:47 AM
Let me have another go, I was not explaining myself very clearly considering the code:

void foo()
{
    int bar;
    Samba(bar);
}


where "Samba" is underlined as a mistyped symbol, what options are you looking for VA to offer, and why? You may be defining and initializing a new variable, or you may be calling a function. The compiler is going to produce an unresolved error from the linker, since it will assume this is a function call, but is it?

The more help I can get from VA the better, but when you start thinking about edge cases some feature requests get a little complex
peterchen Posted - Dec 08 2006 : 7:02:52 PM
When I click refactor on "unknownVariable", I'd like to add a variable (I'm not sure how you would like to add an function call for this?)

Maybe the examples aren't quite clear - I used unknownXxx for the entity that VAX considers unknown and where I start refactoring.

I'm all for chaining simpler operations as a general rule, as long as it remains convenient, e.g. doesn't require complex cursor moves inbetween. As a rule of thumb, if the operaitons can be chained together by a "dumb" keyboard macro, I'm fine.
feline Posted - Dec 08 2006 : 12:09:01 PM
Some of these, if we go down this road, would be done as smaller and simpler operations, so people can then chain them together how they want.

Looking over this, just taking your first example:

void foo
{
    Samba(unknownVariable);
}


are you trying to add a variable or a function call? I cannot tell, but I get the impression that for your idea this distinction might matter.
peterchen Posted - Dec 08 2006 : 06:19:05 AM
I came here to make a similar suggestion - but with MOOORE!

I've tried "Add similar" and some workarounds, technically it works but it's away from the flow.
There is a "mental stopper" in the process: "I want to fix this symbol, so I click this symbol", and VA tells me "dead end road".

The following are my ideas hoiw it could be implemented. I'm flexible - my main wish is that the refactoring starts directly at the unknown symbol.


For an unknown variable:


void foo
{
Samba(unknownVariable);
}

"Create Declaration" -> Ask me for the type. (you can guess if you want). In most cases I need a local variable, but I guess people will expect "global static" and "global extern", too.

If "foo" is a class member, ask me whether I want a local variable, or a private/protected/public one.

Modification: always make it a local variable, and offer a "change Scope" refactoring (private/protected/public class member, external, static)


Similar for Methods:

void foo()
{
int tango = UnknownMethod();
}

again ask me for prototype, and ask me whether I want a global external method (decl in .h, body in .cpp), a static method (only "static" implementation in .cpp file), or a class member (if "Foo" is a class member).

(I'm not sure how a separate "change scope" would work for methods)

For "which base class", offer a separate "move to base class" command (which has been mentioned before I think).

Now for the interesting part :) :

void foo()
{
SomeObject.unknownVariable;
SomeObject.UnknownMethod();
GetSomeObject()->unknownVariable;
GetSomeObject()->UnknownMethod();
}

offer "add member to (type of SomeObject) - if it can be determined.

feline Posted - Dec 07 2006 : 10:07:23 AM
To add this as a class member variable personally I would just copy the line and then trigger Add Similar Member, then paste the variable into the dialog.

To turn it into a parameter I would trigger Change Signature.
dango Posted - Dec 06 2006 : 10:54:45 AM
Ok how about this:

I need to introduce a new variable I type:

void CClass::Foo()
{
std::string m_myString = "Hello World";
}

Then I use a new refactoring to change the scope of the variable to member variable. Or change scope to method parameter.

feline Posted - Dec 06 2006 : 08:16:50 AM
A very interesting idea, and this description, combined with a dialog to edit the type of the variable if you want makes a lot of sense.

I have put in a feature request for this, but don't hold you breath

case=3964

One reason is that this requires VA to properly understand overloaded functions, so we know which overload is being called, so we can pick up the correct return type.
sl@sh Posted - Dec 06 2006 : 03:29:10 AM
Just to add to this idea: in Eclipse it is possible to type a line that introduces a new variable with any type that you want (i. e. int), and initialize it by assigning a value of some kind (i. e. the result of a function call). You can then place the cursor on the new variable's type and press a certain key shortcut, which results in the type of the variable to be changed into the result type of the assignment.

This feature is very handy when you are working with loads of classes and types and don't want to look up (and type out!) all the method return types for any new temporary variable you need to introduce! The typing out part of course isn't quite as tedious when using VAX, but it still requires some work, especially when you work with parametrized (is that a word?) template classes and type qualifiers.

P.S.: I'm not quite sure why Eclipse required 'a' type to be typed out first, maybe the programmers didn't know a good way to recognize whether or not a certain symbol was actually new and settled on this requirement to make sure it is. With VAX's ability to recognize symbols however it should be able to just add the correct type to a new symbol without the help of a dummy type specification, provided there is some term used to initialize the variable.

To give an example - imagine this code segment:
#include <string>
int foo(std::string bar)
{
    separator = bar.find(';');
}

Now put the cursor on 'separator' and open the VAX context menu, select a new method called 'Specify new symbol type'. The result should then look like this:
#include <string>
int foo(std::string bar)
{
    std::string::size_type separator = bar.find(';');
}
schoenherr Posted - Dec 06 2006 : 12:44:23 AM
Of course you would need some form of dialog-box, but it sounds very interesting to me.
feline Posted - Dec 05 2006 : 09:28:13 AM
From a practical point of view I am not sure VA could work out the type of the variable. Consider pointers to a class... is this the base class, one of the derived classes, etc.

Given this restriction how helpful would this really be? Plus are you going to want control over where the declaration is placed?

I am wondering what you are picturing

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000