Smarter and Faster Introduce Parameter in Java

Anna Kozlova

As a logical next step after inplace introduce variable refactoring we did in IntelliJ IDEA 10, version 10.5 will offer inplace introduce parameter.

Here is a brief overview of what we’re working on.

Once called, it will gently ask you to choose a method you want to add parameter to

Note, that you can introduce parameter in hierarchy by selecting the “Use super method of” option.

Then you’ll get a familiar template-like editor with a possibility to change parameter type and name. The refactoring settings you’ve got used to have in the dialog, are now available during template editing. You can make the parameter final, and generate method delegate, to remove unused parameters and replace field usages with getters. When multiple occurrences found you will be able to replace all of them or decide to replace only one right in place. No need to rerun the refactoring to see the results — they are already in the editor.

All method usages are already processed once you finish typing.

Just make sure you have inplace refactoring enabled in ‘IDE Settings | Editor | Enable in place refactorings‘.

The feature will be available in IntelliJ IDEA 10.5 EAP.

Watch our progress on inplace refactorings and let us know what you think!

Comments below can no longer be edited.

19 Responses to Smarter and Faster Introduce Parameter in Java

  1. Alexander says:

    March 24, 2011

    Will be cool, if you’ll introduce Code Snippets Library integration with code completion, like Apple did in his last version of XCode 4.

  2. Cesar says:

    May 17, 2011

    Is there a way to make the popup go away without using the mouse?

  3. Alexander T says:

    May 25, 2011

    Have you seriously introduced this feature without making sure you can navigate the dialog without using a mouse? Can you not even make it go away? In that case my productivity just dropped significantly!

  4. Anna Kozlova says:

    May 26, 2011

    It must be a bug as we checked that it works without mouse at least on Windows and Linux. Could you please be more specific and file a bug report?
    Thank you

  5. Alexander T says:

    May 26, 2011

    Hi Anna,

    I figured out after a while that the ‘stuck dialog’ indeed is a bug, which occurs only during the ‘introduce parameter’ refactoring. For me it’s 100% reproducable, I will check with some colleagues and get back to you via a bug report.

    I still haven’t figured out how to change the in-place settings with the keyboard, but it was easy enough to disable the in-place refactoring (Settings->Editor->Enable in place refactorings), so I am happy chappy again 🙂


  6. Volodymyr Melymuka says:

    May 27, 2011

    Here’s example:
    * @author Volodymyr Melymuka
    * @since 27/05/11 11:44
    public class Bug {
    Object o;
    void doPrint(Object o) {
    System.out.println(“o = ” + o.toString());
    void printObject() {
    doPrint(new Object());
    /* end of*/
    # then in method doPrint(Object o) select o.toString()
    # press Ctrl+Alt+P (introduce/extract Parameter)
    # tooltip window pops up
    # signature of doPrint() changes from original doPrint(Object o) to doPrint(Object o, String s)
    # in tooltip check ‘Remove parameter ‘o’ no longer used’ -> the signature does not change
    # in previous versions of IDEA (or with ‘inplace refactorings -> disabled’ a change happens for method printObject() from
    void printObject() {
    doPrint(new Object());
    void printObject() {
    final Object o1 = new Object();
    # in IDEA 10.5UE with ‘inplace refactorings -> enabled’ above change does not happen having left code in non compilable state.
    # The tooltip window never goes away.
    So for now ‘introduce parameter’ works 100% wrong and is unusable forcing me to disable ‘inplace refactorings’ for a time when I need to do parameter extracting.
    p.s. All other inplace refactorings (variable/method renamings) work perfectly.

  7. Anna Kozlova says:

    June 1, 2011

    Volodymyr, I’ve checked the example and it works for me here. Actually parameter would be deleted only on template close (on tab or enter). If it doesn’t occur, most probably that that is a bug which was already fixed in the latest IDEA 10.5.1 EAP. Could you please try it and if it would be still reproducible, file a bug? Thank you

  8. Volodymyr Melymuka says:

    June 2, 2011

    Anna, thanks for your feedback! I’ll definitely try it and will reply here.

    BTW later I’ve found issue that seems similar in being fixed in rev.108.258 . And current latest 10.5.1 EAP build rev. is 107.148 (taken from here: ) – so maybe I won’t get mentioned bug fixed in 10.5.1 EAP. I’ll try anyway.

  9. Anna Kozlova says:

    June 2, 2011

    Volodymyr, fix for IDEA-67927 was backported in 10.5.1 branch and is available in build 107.148. Thanks

  10. Volodymyr Melymuka says:

    June 3, 2011

    Anna, I tried 107.148 and can say that now behavior is as follows:
    IDEA 10.5.1 EAP XENA 107.148
    Action – introduce new parameter with removing not used one:
    void doPrint(Object o) {
    System.out.println(”o = ” + o.toString());
    I select o.toString() and hit Ctrl+Alt+P
    Problem happens with these prerequisites:
    1)’inplace reactorings’ are enabled
    2)Spring Support plugin is turned on
    3)At least one Spring facet is registered in project.

    ! Please note that without point number 3 everything works perfectly !

    So if I register at least one Spring facet – inplace parameter refactoring fails in 10.5 or causes modal window in 10.5.1 (107.148)
    If I then delete all Spring facets from project – inplace parameter refactoring starts working as it should (described in first post)

    Should I reopen the bug or file a new one?

    Thank you for your answer.

  11. Anna Kozlova says:

    June 3, 2011

    No, actually it is by design that modal dialog is opened in 10.5.1. I hope that IDEA 11 would have better solution for the problem (we are going to redesign inplace introduces anyway). Thank you

  12. Volodymyr Melymuka says:

    June 7, 2011

    Anna, is it really by design that when you have at least one Spring facet configured – in-place refactoring fails and is being replaced by modal window? And in case of no Spring facets in-place refactoring works plain and smooth?
    Thank you for your answer.

  13. Anna Kozlova says:

    June 7, 2011

    Yes, that is the correct behaviour for now. We already have nearly the same situation with inplace rename: you are able to rename variable inplace but that is not possible with field or method – dialog is shown instead. I hope that it would be changed in IDEA 11. Thanks

  14. Suresh says:

    June 7, 2011

    I am using
    #IU107.105 May16th Build , MAC

    This refactoring doesnt work as described for me anymore

    void function() {

    when i highlight the “constant” and hit command alt p, I a var defined in the function but it doesn’t replace the “constant” with the variable.

    anyone else facing this?


  15. Anna Kozlova says:

    June 8, 2011

    Suresh, that is most probably the bug It is already fixed in the latest 10.5.1 EAP. As workaround (before 10.5.1 is out) you may disable inplace refactorings in File|Settings|Editor. There are other options to workaround, please see corresponding bug comments and comments here. Sorry for the inconvenience.

  16. Suresh says:

    June 8, 2011


    does this have it?


  17. Anna Kozlova says:

    June 8, 2011

    Yes, it contains the fix.

  18. Suresh says:

    June 8, 2011

    yeah just downloaded it and tested it, the refactoring isnt inplace anymore, was it more of a revert than fix?. neways that works for me for now


  19. Anna Kozlova says:

    June 9, 2011

    The inplace refactoring was disabled for some configurations, e.g. when there is a Spring Facet with configured aop pointcuts. That should be changed in the upcoming IDEA 11 release. Thank you


Subscribe for updates