The Extract Define refactoring method defines the selected set of tokens as macro using
and replaces the set of tokens with macro call in the code; macro definition can be located in the current file or moved to the
related header file.
Extract define in-place
To perform Extract define in-place:
In the editor, select the expression to be replaced with a macro call. You can do that yourself
or use the smart expression selection feature to let CLion help you. So, do one of the following:
- Highlight the expression. Then choose from the main or context menu.Alternatively, press Ctrl+Alt+D.
- Place the cursor before or within the expression, choose from the main or context menu, or press Ctrl+Alt+D. In the Expression pop-up menu, select the expression by clicking the required expression. Alternatively, use the Up and Down arrow keys to navigate to the expression of interest, and then press Enter to select it.
- If more than one occurrence of the selected expression is found, select Replace this occurrence only or Replace all occurrences in the Multiple occurrences found pop-up menu. To select the required option, just click it. Alternatively, use the Up and Down arrow keys to navigate to the option of interest, and press Enter to select it.
- Select Put to header check box if you want to move macros definition to the header file.
Specify the name of the macro. Do one of the following:
- Select one of the suggested names from the pop-up list. To do that, double-click the suitable name. Alternatively, use the Up and Down arrow keys to navigate to the name of interest, and Enter to select it.
- Edit the name by typing. The name is shown in the box with red borders and changes as you type. When finished, press Enter.