Posts Tagged ‘Intentions’

New String-related Intentions for Groovy

Wednesday, September 23rd, 2009

With the latest Maia EAP Groovy language support is improved with several new GStrings intention actions.

Now you can convert string concatenations to GStrings…

…and back simply by pressing Alt+Enter, Enter.

Also, IntelliJ IDEA is now aware of that braces can be skipped in some GString injections.

Listeners and Adapters

Thursday, September 3rd, 2009

Occasionally implementing a Listener leads to an explosion of ugly empty boiler-plate methods. In such cases it is usually better to extend a matching adapter class and only override the needed methods.

The next IntelliJ IDEA Maia EAP build will make switching between implementing a Listener or extending an Adapter easier — with newly added Listener implementation could be replaced with Adapter extension inspection (also announced on Twitter).

This new inspection quickly highlights any implementations of Listeners which contain empty methods and offers to replace them with an extension of the relevant Adapter class.

A quick Alt+Enter, Enter replaces the verbose listener code by a more compact use of an Adapter. If you ever need to return to an implementation of a Listener, there is a new complementary intention to make this journey back quick and painless — Replace Adapter Extension with Listener implementation.

Flip Setter Call Intention Action in Maia

Tuesday, June 2nd, 2009

Two-way synchronization between different data models is a common routine task and often developers are stuck with manual copying of data from one model to another for many reasons: model complexity, impossibility to create a simple binding, etc. For example, we have a settings model and an UI to configure it. Traditional approach suggests implementing two methods:

  • Initializing UI from settings
  • Persisting changes from UI to settings


Next, we need to implement a method (say, saveSettings), similar to initUI where UI changes are persisted to the ProxySetting object — quite boring, isn’t it?

How to do it quicker than just writing from scratch? In Maia we’ll do it twice as easy: copy the body of initUI method to saveSettings, select the just pasted code and press Alt+Enter.
Then, select Flip Setter Call intention action and enjoy.

User Defined Language Injection

Friday, March 20th, 2009

In IntelliJ IDEA you can quickly configure language injection for XML tags, attributes and Java method parameters and their return values. Just use Inject Language Intention on the code like this:



and it will immediately turn to:




And you get the complete coding assistance, with syntax and error highlighting, completion and navigation.

This functionality is provided by the bundled IntelliLang plugin. The full configuration is available for edit in the Settings dialog (see screenshot below). Default configuration includes various mappings like RegExp language in Pattern.compile(), SQL in JDBC API calls, JPA & Hibernate QL injections and much more.

Making Spring Autowired Dependencies Explicit

Tuesday, March 17th, 2009

Try invoking Make autowired dependencies explicit intention actions for beans or contexts that use autowire attribute.



IntelliJ IDEA will find all beans that can be autowired with current bean and generate appropriate properties with correct reference attribute.