Search code examples
javaeclipseintellij-ideaautocompleteintellisense

How to fix IntelliJ IDEA method parameter auto-completion?


I am using IntelliJ IDEA 15, and I noticed that (by default) Eclipse offers a much more convenient auto-completion, when it comes to writing method calls, which require multiple parameters.

Eclipse automatically fills in default parameters and allows you to quickly navigate through them by pressing Tab:

enter image description here

However, IntelliJ IDEA does not handle it as conveniently and makes you write them manually:

enter image description here

Is there a way to make IntelliJ IDEA, handle method call auto-completion in a similar way to Eclipse's, and pre-write all the parameters for you, having you just press Tab (or another key) to navigate through them? If it is not possible in original IntelliJ, is there an add-on/plugin/external tool that will improve the intelligent code completion in such cases?


Note: I am not being lazy, it just gets quite annoying, having to manually complete each parameter and put a comma after each one, when code completion should do it for you.


Solution

  • IntelliJ doesn't do it and AFAIK there isn't a plugin for it.
    There is no solution for you (unless you built a plugin yourself, but then you'd just have another job to maintain that plugin)

    The alternative is to break the habit/need for it and use IntelliJ's Code Completion shortcuts:

    • Ctrl+P to view possible parameters for function.
    • Ctrl+Shift+Space to list the possible variables that could be entered as a parameter in the respective parameter position (based on type).
      This also enters a comma if another parameter is required for the function.

    Hardcoding numbers/strings as parameters to a custom function wouldn't be advisable as that negates the point of the parameters. It's better practice and more common to pass in a pre-defined variable; At which point Ctrl+Shift+Space is the easiest way for Code Completion.
    This would also prevent you from closing quotations and adding commas.

    Also note: IntelliSense is Microsoft's Intelligent Code Completion implementation which neither IntelliJ nor Eclipse uses.


    As frant.hartm states in their answer:

    Unfortunately the view of Intellij developers is that this feature would be too error prone. See this issue on youtrack.

    They even state that people are welcome to make a plugin that does this.