Blog

IntelliJ 8: Even smarter code completion!

11 Nov, 2008
Xebia Background Header Wave

Smart code completion has been improved in IntelliJ 8. In the new version of JetBrains’ IDE ‘even smarter’ code completion is added. But first I’ll explain what smart code completion is! Basically, it’s code completion on steroids, which takes the type of the variable into account too which the new value is assigned to. So, if your assigning a value to a variable of type String, smart code completion will only display methods which are compatible with a String type, and filters the list of methods accordingly. It does even a lot more than this, which you can read about here

The ‘even smarter’ code completion extends this smart behiour to objects two steps away. This best explained with some code samples:

public class Person {
   private Address address;
   // getters & setters
}
public class Address {
   private StreetName streetName;
   // getters & setters
}
public class StreetName {
   private String name;
}

And you type the following:

StreetName streetName = person.

When pressing Ctrl+Shift+Space once, nothing will happen, since no methods on person exists which are compatible with the StreetName type. However, pressing it twice will automatically find the getStreetName in the Address class, so the final result will look like this, which is a real timesaver, especially in an environment with loads of domain classes (instead of using Strings for names, etc). The final result is shown below!

StreetName streetName = person.getAddress().getStreetName()
Questions?

Get in touch with us to learn more about the subject and related solutions

Explore related posts