RFE: Insert return type + variable

For example:


I can get the 'someMethod()' auto inserted by typing c. then hitting ctrl-space.

How about putting the cursor at the start of the method call and hitting ctrl-space, and having an intention popup: "Assign return value to variable"

This would insert something like:

Map> aVariableName = c.someMethod(); or maybe based on a config setting do this: (split assignment and declaration) Map>]]> aVariableName = null;
aVariableName = c.someMethod();

I had a quick look around the menus and didnt see any options that looked like they would do this - if IDEA can do this now, please point me in the right direction.


Comment actions Permalink

"Introduce Variable" (Ctrl-Alt-V) does exactly this, for any expression selected. It's been a long time since I've actually declared a local variable by typing out the return type and variable name.

--Dave Griffith

Comment actions Permalink

Damn, so it does {:-) Thanks very much.

I knew about the ctrl-alt-v working when you selected an expression, I didnt realise it worked at the start. Cool.



Please sign in to leave a comment.