Archive for August 20th, 2008

Smart Type Completion Becomes Even Smarter

Wednesday, August 20th, 2008

Most of you are aware of IntelliJ IDEA smart type completion feature that is invoked with Ctrl+Shift+Space shortcut. If you are not familiar with this feature, I totally recommend you to read the post about it, because this thing is a real developer’s gem. Besides, in the latest IntelliJ IDEA 8 Milestone 1 release, this gem became even shinier.

Long story short, let’s cut to the chase and inquire into the matter through the examples.

  • Consider we have the following code:
    Collection is expected
    If we press Ctrl+Shift+Space and get no results, because a collection type is expected, we can press Ctrl+Shift+Space again to make IntelliJ IDEA search for arrays with the same component type and suggest to convert them with Arrays.asList() call.
    Collection is expected 2
  • Press Ctrl+Shift+Space twice, and IntelliJ IDEA will search for chained expressions of the expected type.
    Chained Expressions
  • When an array type is expected, but no suggestions can be made in the current context, press Ctrl+Shift+Space one more time. IntelliJ IDEA will search for collections with the same component type and suggest to convert them with toArray() call.
    Array type expected
    Array type expected 2
Technorati tags: , ,