CLion 2016.2 Help

Extract Parameter

The Extract Parameter refactoring is used to add a new parameter to a function declaration and to update the function calls accordingly.

Example

BeforeAfter
cl_extractParameterBefore
cl_extractParameterAfter

To extract parameter

  1. In the editor, place the cursor within the expression or local variable declaration to be replaced by a parameter.
  2. Do one of the following:
    • Press Ctrl+Alt+P.
    • Choose Refactor | Extract | Parameter on the main menu or on the context menu.
  3. If more than one expression is detected for the current cursor position, the Expressions list appears. If this is the case, select the required expression. To do that, click the expression. Alternatively, use the Up and Down arrow keys to navigate to the expression of interest, and then press Enter to select it.
    cl_extractParameterExpressions
  4. In the Extract Parameter pop-up:
    1. Specify the parameter name in the Name field.
    2. If more than one occurrence of the expression is found within the function body, you can choose to replace only the selected occurrence or all the found occurrences with the references to the new parameter. Use the Replace all occurrences check box to specify your intention.
  5. Preview and apply changes.
    cl_extractParameterName

See Also

External Links:

Last modified: 22 November 2016