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.

This entry was posted in New Features and tagged , , . Bookmark the permalink.

10 Responses to Chained expression completion in IntelliJ IDEA 11.1

  1. OlegYch says:

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

  2. Hyperion says:

    Fantastic, this will help alot :)

  3. Tomek N. says:

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

  4. Philip Herbst says:

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

  5. Philip Herbst says:

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

  6. steve says:

    Will this work in the Scala plugin?

  7. Peter Gromov says:

    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. Peter Gromov says:

    Philip, fixed, thanks!

  9. Zyava says:

    PHP version please

  10. Taras Tielkes says:

    Request for Scala is here (add your votes):
    http://youtrack.jetbrains.com/issue/SCL-4121

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">