Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can IntelliJ auto-complete constructor parameters on "new" expression?

If my class has a non-empty constructor, is it possible to auto-complete parameters in the new expression?

With Eclipse, if you press ctrl+space when the cursor is between the parenthesis:

MyClass myObject = new MyClass(); 

it will find the appropriate parameters.

-->  MyClass myObject = new MyClass(name, value); 

When I use ctrl+shift+spacebar after the new, Intellij shows me the constructors, but I can't choose one for auto-completion. Am I missing an option?

like image 747
Loic Avatar asked Jan 27 '11 10:01

Loic


2 Answers

I usually start with CtrlP (Parameter Info action) to see what arguments are accepted (auto guess complete is way to error prone in my opinion). And if as in your case you want to fill in name type n a dropdown menu appears with all available variables/fields (etc) starting with n Arrow Up/Down and Tab to select name, or CtrlSpace to select a method (or even CtrlAltSpace to be killed by suggestions;-), followed by , and v Tab for value.

like image 104
osundblad Avatar answered Oct 29 '22 15:10

osundblad


Well I used the eclipse key map where Parameter Info is unassigned. Here is how to change that:

enter image description here

like image 42
joecks Avatar answered Oct 29 '22 15:10

joecks