Chained expression completion in IntelliJ IDEA 11.1
February 20th, 2012 by Peter GromovIf 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.
Tags: Code Completion, Groovy, Java

February 20th, 2012 at 12:36 pm
Awesome!
Long awaited.
Now just please add it to scala plugin as well.
February 20th, 2012 at 1:13 pm
Fantastic, this will help alot
February 20th, 2012 at 1:27 pm
+1, great! And also +1 for Scala support - or at least make it work for Java classes in Scala code.
February 20th, 2012 at 5:25 pm
Works nicely for *Utils classes, but it doesn’t seem to work for Assert.*
February 20th, 2012 at 5:37 pm
Slight correction: It will work, if i exclude java.lang.AssertionError from autocompletion.
February 21st, 2012 at 3:47 am
Will this work in the Scala plugin?
February 21st, 2012 at 3:54 am
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.
February 21st, 2012 at 1:22 pm
Philip, fixed, thanks!
February 23rd, 2012 at 2:43 pm
PHP version please
March 15th, 2012 at 10:42 am
Request for Scala is here (add your votes):
http://youtrack.jetbrains.com/issue/SCL-4121