IntelliJ IDEA 14.1.0 Help

Intention Actions and Quick Fixes Basics

While inspections provide quick-fixes for code that has potential problems, intentions help you apply automatic changes to the code that is correct.

To get a list of intentions applicable to the code at the caret, just press Alt+Enter.

In this section:

Optimize statements and manage braces

Since the IDE is aware of the data flow in your code, it can help you optimize Boolean conditions and transform if/else statements:

intention1

With intentions you can, for example, automatically add and remove braces for your statements:

intention2

String concatenation

If you have String concatenation, the IDE can help you replace it with a String.format expression or a StringBuilder pattern.

intention3

Switch between loop declaration styles

With intentions you can also switch between loop declaration styles or even reverse its direction.

intention4

Math expressions

If you have a complicated math expression, the IDE will offer you to simplify an expression or possibly clarify it with parentheses.

intention5

Disable intention

If you don’t want to see a certain intention, you can disable it by selecting the right arrow on the intention.

intentionActionDisable

Settings

Find the complete list of intentions (several hundred in total), grouped by language and framework, in the Intentions page of the Settings dialog. Here you can enable/disable whole groups of intentions:

intention6

See Also

Last modified: 12 August 2015