Auto-complete of local variable that matches parameter name

More often than not, I sem to use encounter situations when writing a method (including constructor) call where there is a parameter name in the method call that I have intentionally used as the name of a local variable or parameter. While I can start typing the first characters of the locally named entity that matches the called method/constructor parameter name, it would be nice if RS detected matching names and preinserted them in the appropriate plaes in the call statement.

This is quite similar to the check that implementations of interface/base methods use the same name for the same parameters.

Also, when entering a name in a point where something of a specific type is required, it would be helpful if RS initially filed the autocomplete combobox with just those entities that have the ame desired type. Granted there are indirect way to return something of type X (such as instance calls or static calls), but I think more often than not if a body code already has something of type X, and when entering code a situation is encoutered that requires something of type X, then an initial guess by RS that the existing entity of type X will be the desired name to be entered.

2 comments
Comment actions Permalink

I think what you want is CtrlShftSpace which does a smart insert, reducing
a list to only those things which are valid. eg, if you have a method with
a parameter which is an enum then when filling that parameter in a method
call in pressing CtrlShftSpace will give you just a list of values of
that enum (or any variables in scope which are of the type of that enum I
believe)

"Brian Strelioff" <BKStrelioff@Hotmail.com> wrote in message
news:23785417.42501212105104805.JavaMail.jive@app4.labs.intellij.net...

More often than not, I sem to use encounter situations when writing a
method (including constructor) call where there is a parameter name in the
method call that I have intentionally used as the name of a local variable
or parameter. While I can start typing the first characters of the locally
named entity that matches the called method/constructor parameter name, it
would be nice if RS detected matching names and preinserted them in the
appropriate plaes in the call statement.

>

This is quite similar to the check that implementations of interface/base
methods use the same name for the same parameters.

>

Also, when entering a name in a point where something of a specific type
is required, it would be helpful if RS initially filed the autocomplete
combobox with just those entities that have the ame desired type. Granted
there are indirect way to return something of type X (such as instance
calls or static calls), but I think more often than not if a body code
already has something of type X, and when entering code a situation is
encoutered that requires something of type X, then an initial guess by RS
that the existing entity of type X will be the desired name to be entered.



0
Comment actions Permalink

Hello,

See ReSharper -> Code -> Complete Code -> Smart.

It will filter the completion items by their type, and prefer those variables
whose name matches the parameter name.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Please sign in to leave a comment.