Posts Tagged ‘Intentions’

How to check your RegExps in IntelliJ IDEA 11?

Friday, November 4th, 2011

In IntelliJ IDEA 11 you can check your Regular Expressions while coding without leaving the IDE. Just invoke the ‘Check RegExp’ intention action on a regular expression and play!

Tip: You can turn any string into a regular expression by injecting RegExp language. Try the ‘Inject Language’ intention action.

Quick prototyping in Groovy with “Convert Map to Class” intention

Tuesday, April 19th, 2011

Sometimes it is helpful to use a Map for fast prototyping of classes with some properties but without any logic. But in the end it would be nice to have a real class. In IntelliJ IDEA you can get it by invoking “Convert Map to Class” intention on a map.

You only need to type a name and a package for a new class:

And you’ll get something like this…

and a UserInfo class:

Quick and easy, right?

It is not something new, it’s been in IntelliJ IDEA for a while already. We just felt you might not be aware of it.

XML improvements in IntelliJ IDEA X

Thursday, July 8th, 2010

There are few small, but very useful improvements in XML editing will be available in IntelliJ IDEA 10. All of them are very handy when edit XML files like schemes, JSPs, MXMLs, etc. First of these improvements is inspection detecting unused namespace declarations.

Others include namespace prefix intentions which allow you to rename, remove or introduce namespace prefixes. Want to make you schema file lighter? Not a problem:

Rename in place:

Or introduce new namespace prefix:

Find usages works as well. Enjoy them in first IntelliJ IDEA X EAP soon.

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.