CodeRush-like create variable functionality?

Hi there,

In the gap between updating to VS2008 and our company deciding that they needed to purchase the upgrade for ReSharper I was stuck with a vanilla IDE. Not being satisfied with the time it took me to do some things I decided to play with CodeRush Express. One of the features of CodeRush Express that I really like is the way that it is possible to quickly create a variable simply by typing an expression which results in a return value then pressing a key combination.

Lets say, for example, that I wanted to create a new Something and assign it to a variable. In CodeRush express, I simply type

new Something()

and hit the hot-key (typically ctrl-`). A menu pops up, and depending on the context hitting enter typically results in code similar to the following

Something something = new Something();

The variable name, and variable type are both editable (if desired). The same technique works with return values from methods, etc.

Does similar functionality exist in ReSharper? I got used to having it available and I don't want to go back to typing extra if I don't need to. :-) (I'm using the 5.0 EAP build, if that helps.)

Regards,
Richard

4 comments

Hello,

>

Lets say, for example, that I wanted to create a new Something and assign it  to a variable. In CodeRush express, I simply type

new  Something()


Use "Introduce variable" refactoring for it.

> The variable name, and variable type are both editable (if desired). The  same technique works with return values from methods,  etc.


R# have the context action "Return this value" for this case.

Best  regards,
Alexander Nesterenko
ReSharper developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with  pleasure!"

0

Hello,

Lets say, for example, that I wanted to create a new Something and
assign it to a variable. In CodeRush express, I simply type

new Something()


Use "Introduce variable" refactoring for it.


The variable name, and variable type are both editable (if desired).
The same technique works with return values from methods, etc.


R# have the context action "Return this value" for this case.

Best regards,
Alexander Nesterenko
ReSharper developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


0

Sadly, invoking "Introduce Variable" in this context generates errors (at least with the EAP build).

Issues have been submitted to Jira. Unfortunately there were quite a few of them and I have no clue which one represents the root cause. The issues are: RSRP-12600 through RSRP-12619 (I think).

Thanks for the suggestion though! It'll probably be the right one when the code is fixed.

0

Using ReSharper 4.5 in VS2008, I use "Introduce Variable" keyboard shortcut all the time.  It works really well, and really

cuts down on the amount of typing I have to do.

It does matter where you cursor is and what you've typed.  For example, if you just type "foo()"  (no quotes) and then press the Introrduce Variable refactoring keystroke, it works great.  If you went ahead and typed the semicolon at the end and then tried it, it would fail.  Alternatively, you can select the exact code you'd like to replace with a variable, and then perform the refactoring.

0

Please sign in to leave a comment.