Chained expression completion in IntelliJ IDEA 11.1

If you use completion autopopup in IntelliJ IDEA 11, you may have seen “n variants…” suggestions:

This means there are two StringUtil classes available, neither of them is imported, and IDE can’t choose which of them to put to the first place. When you choose such variant no new import statements will be added. The good side is that you won’t get wrong imports after pressing space, dot or a bracket. The bad side is that you eventually have to face this choice: you may either explicitly invoke completion (Ctrl+Space) again or choose the correct qualified name from the auto-import hint which appears after choosing the item.

Here’s a good news though, now (since IntelliJ IDEA 11.1) you don’t ever have to choose the qualified name. In this particular case, you just type a dot, no import is inserted as before, but the next completion autopopup will list all the possible static members from both possible StringUtil classes:

Needless to say, after you choose the method you want all the necessary imports will be added.

In fact, this feature is even more powerful. It tries to enumerate all the completion variants matching the non-existent qualifier and suggest chained calls based on this. So you may spare some typing even if you don’t use autopopup (or have hit dot too early before it appeared):

Ah, yes, this works in Java and Groovy code.

Comments below can no longer be edited.

10 Responses to Chained expression completion in IntelliJ IDEA 11.1

  1. Avatar

    OlegYch says:

    February 20, 2012

    Long awaited.
    Now just please add it to scala plugin as well.

  2. Avatar

    Hyperion says:

    February 20, 2012

    Fantastic, this will help alot 🙂

  3. Avatar

    Tomek N. says:

    February 20, 2012

    +1, great! And also +1 for Scala support – or at least make it work for Java classes in Scala code.

  4. Avatar

    Philip Herbst says:

    February 20, 2012

    Works nicely for *Utils classes, but it doesn’t seem to work for Assert.*

  5. Avatar

    Philip Herbst says:

    February 20, 2012

    Slight correction: It will work, if i exclude java.lang.AssertionError from autocompletion.

  6. Avatar

    steve says:

    February 21, 2012

    Will this work in the Scala plugin?

  7. Avatar

    Peter Gromov says:

    February 21, 2012

    No, this doesn’t currently work in Scala plugin, but your wishes have been forwarded to its developers 🙂

    Philip, thanks for reporting the problem, I’ll have a look at it.

  8. Avatar

    Peter Gromov says:

    February 21, 2012

    Philip, fixed, thanks!

  9. Avatar

    Zyava says:

    February 23, 2012

    PHP version please

  10. Avatar

    Taras Tielkes says:

    March 15, 2012

    Request for Scala is here (add your votes):

Discover more