CLion 2017.1 Help

Pull Members Up

Basics

The Pull Members Up refactoring allows you to move class members to a base class.

Example

BeforeAfter
/help/img/idea/2017.1/cl_PullMemebrsDownBefore.png
/help/img/idea/2017.1/cl_PullMemebrsDownAfter.png

Pulling members up

  1. Select the class to be moved to a superclass.
  2. On the main menu or on the context menu, choose Refactor | Pull Members Up. The Pull Members Up dialog box appears.
  3. Select the destination object (superclass).
  4. In the Members section, select the members you want to move.
  5. Click Refactor to pull the selected members to their destination.

Pulling up the dependent members

Let's consider the following sample of code:
/help/img/idea/2017.1/cl_PullMemebrsUpError1.png
As you can see, there is a dependency between variables d1 and d3. If you apply Pull Members Up refactoring to class ChildClass and try to select d3 to be moved, and leave d1 in the class, CLion highlights the problem member in Pull Members Up dialog, as following:
/help/img/idea/2017.1/cl_PullMemebrsUpError2.png

Trying to proceed with extract, you will get the following warning message:

/help/img/idea/2017.1/cl_PullMemebrsUpError3.png

Choose Continue to ignore the problem and proceed with refactoring, or Cancel to return back and resolve it. Also you can observe the conflict in Find Tool Window.

See Also

Last modified: 19 July 2017