On this page:
- Move refactorings: basics
- Moving a file or a directory to another directory
- Moving a class member to another class, existing or new:
- Moving a declaration
- Moving a declaration or member that influence the others
Move refactorings: basics
The Move refactorings allow you to move files, directories, class members and declarations within a project. CLion tracks these movements and automatically corrects all references to the moved symbols in the source code.
- The Move File refactoring moves a file to another directory.
- The Move Directory refactoring moves a directory to another directory.
- The Move Member refactoring moves the selected class member to a new or an existing class.
- The Move Declaration refactoring moves the top level type declaration to a new or an existing file
Moving a file or a directory to another directory
To move a file or directory to another directory, follow these steps:
- Select the file or directory in the Project tool window.
Do one of the following:
- On the main menu, choose , and then choose .
- On the context menu of the selection, choose , and then choose .
- Press F6.
The dialog that opens depends on the type of the selected symbol.
- In the To directory field, specify the folder to move the selected file or folder to. Choose an existing folder from the drop-down list or type the full path to the parent folder to be created.
- To have the references to the selected file or folder updated according to the refactoring result, select the Search for references check box.
Moving a class member to another class, existing or new:
To move a class member to the new class, follow these steps:
- In the Editor or Structure view, select the class member to be moved
- Do one of the following:
- Type the destination class name or click the button to choose.
- Select the class members to be moved to the specified class.
Moving a declaration
To move a top level declaration to another file, follow this steps:
- In the editor or Structure view, select the declaration to be moved to another file.
- Do one of the following:
- Type the destination file name or click the button to choose.
- Select the declaration to be moved to another file.
Moving a declaration or member that influence the othersLet's consider the following sample of code: As you can see, variable
d3here depends on variable
d1. If you apply Move Declaration refactoring to the above class and try to select declaration of class
SubCLassto be moved, and leave declaration of
d1at the initial position, CLion warns you about dependency: where declaration of
d1is highlighted with blue. The same rules are applicable to Move Members refactoring.