CLion 2016.2 Help

Extract Typedef

Basics

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.

Example

BeforeAfter
cl_extractTypedefBefore
cl_extractTypedefAfter

Extract Typedef in-place

To perform Extract typedef in-place:

  1. 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 Refactor | Extract | Extract Typedef from the main or context menu.
    • Alternatively, press Ctrl+Alt+K.
  2. 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.
    cl_extractTypeDefMultipleOccurrence
    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.
  3. Select Put to header check box if you want to move created typedef definition to the header file.
  4. 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.

See Also

External Links:

Last modified: 20 July 2016