As part of the Eclipse Juno release, a new project, Eclipse Code recommenders joins the train.
The idea of the code recommenders is to adjust and filter the set of proposals given when the code proposal key sequence is triggered. By default, Eclipse will show the list of public methods (or fields) in alphabetical order. However, when coding against unfamiliar APIs, or ones with many overloaded methods (Quick! Which of the 6 Date constructors is the right1 one to use?), it is not always clear which one should be called.
The code recommenders tool has a database of prior code samples, along with frequencies of the method callers, and uses that to prioritise which method or constructor to prompt for. If most Date constructors use either the zero argument (or single long argument), then these two choices will be presented first, with other ones filtered out. In addition, the proposal can use context sensitive information, so if completing a method call of timezoneOffset = date.get it will prompt the getTimezoneOffset() method as the first selection.
The recommenders project also provides a list of context-sensitive snippets of code. These can be constructed manually, or inferred from existing code samples. As with other Java templates (such as main or syserr), these can be used to quickly implement code.
InfoQ caught up with Marcel Bruch, creator of the recommenders project, and started by asking what prompted the creation of the project:
The idea of the code recommenders is to adjust and filter the set of proposals given when the code proposal key sequence is triggered. By default, Eclipse will show the list of public methods (or fields) in alphabetical order. However, when coding against unfamiliar APIs, or ones with many overloaded methods (Quick! Which of the 6 Date constructors is the right1 one to use?), it is not always clear which one should be called.
The code recommenders tool has a database of prior code samples, along with frequencies of the method callers, and uses that to prioritise which method or constructor to prompt for. If most Date constructors use either the zero argument (or single long argument), then these two choices will be presented first, with other ones filtered out. In addition, the proposal can use context sensitive information, so if completing a method call of timezoneOffset = date.get it will prompt the getTimezoneOffset() method as the first selection.
The recommenders project also provides a list of context-sensitive snippets of code. These can be constructed manually, or inferred from existing code samples. As with other Java templates (such as main or syserr), these can be used to quickly implement code.
InfoQ caught up with Marcel Bruch, creator of the recommenders project, and started by asking what prompted the creation of the project: