CLion 2018.2 Help

Intention actions

CLion helps you handle the situations when you use classes that haven't been imported, or methods that haven't been written etc., which can result in errors. When a possible problem is suspected, CLion suggests a solution, and in certain cases can implement this solution (properly assign variables, create missing references and more). Besides syntax problems, CLion recognizes code constructs that can be optimized or improved, and suggests appropriate intention actions, denoted with the special icons.

Intention action types

ItemIconDescription
Intention actions suggestedicons actions intentionBulbA yellow bulb indicates that CLion just proposes to alter your code. It covers a range of situations from warning correction to suggestions for code improvement (like micro-refactorings).
Specific intention actionicon intentionActionEnabledThis sign appears in the suggestion list before each specific intention action. If an intention action alert is disabled, the sign turns to icon intentionActionDisabled. Disabled intention action is still available and can be enabled again.
Quickfix suggestedicons actions quickfixBulbA red bulb with an exclamation mark indicates that CLion suggests a way to fix an error. It is related to Create from usage intentions and Quick fixes.
cl redbulb
DisabledintentionBulbGreyAlert is disabled, but the intention action is still available and can be enabled again.

Support in languages

In CLion, you can apply intention actions to code in all the supported languages except for JSON and YAML (see CLion Features in Different Languages, table Code analysis and assistance). Below you can find code snippets in four languages showing examples of different types of the Intentions:
Example: intention action on C++
Example: intention action on Objective-C
Example: intention action on Python
Example: intention action on JavaScript

Applying intentions

  1. Click the light bulb icon (or press Alt+Enter) to open the list of suggestions.
  2. Select an action from the list.

Configuring intentions

You can view the full list of available intention actions, and disable actions that you don't need at the moment:

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), select Editor | Intentions.
  2. For each intention action, you can see a description and an example.

    If you want to disable an intention, deselect the checkbox next to it.

  3. Apply the changes and close the dialog.
    Intentions settings

Disabling intentions on-the-fly

  1. Click the light bulb icon (or press Alt+Enter) to open the list of suggestions.
  2. Select the action you want to disable, and click the right arrow.
  3. Select Disable <intention action name>.
    cl intentions disable
Last modified: 18 September 2018

See Also

Reference: