The Extract Typedef refactoring method changes the selected declaration of a type to the
typedef definition. You can apply Extract Typedef when actual declaration is cumbersome, potentially confusing, or likely to vary from one implementation to another, or just to make code presentation more clear and readable.
Extract Typedef in-place
To perform Extract typedef in-place:
- In the editor, select the type declaration to be re-declared. 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 token. Then choose from the main or context menu.
- Alternatively, press Ctrl+Alt+K.
- 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.
- In the Typedef pop-up menu, select the type name by clicking the required name. Alternatively, use the Up and Down arrow keys to navigate to the name of interest, and then press Enter to select it.
- Select Put to header checkbox if you want to move created
typedefdefinition to the header file.
- Specify the name of the new type. 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.