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
Item | Icon | Description |
---|---|---|
Intention actions suggested | A 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 action | This sign appears in the suggestion list before each specific intention action. If an intention action alert is disabled, the sign turns to . Disabled intention action is still available and can be enabled again. | |
Quickfix suggested | A 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. | |
Disabled | Alert 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:Applying intentions
Click the light bulb icon (or press Alt+Enter) to open the list of suggestions.
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:
In the Settings/Preferences dialog (Ctrl+Alt+S), select .
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.
Apply the changes and close the dialog.
Disabling intentions on-the-fly
Click the light bulb icon (or press Alt+Enter) to open the list of suggestions.
Select the action you want to disable, and click the right arrow.
Select
.