In the Safe Delete dialog that opens, select the corresponding checkboxes to look for usages of the file in comments and strings and for occurrences of the file in text. In the Project tool window, select the file to remove and choose Refactor | Safe Delete from the context menu or press Alt+Delete. WebStorm looks for the usages of the file to be deleted and shows them in the Usages Detected dialog. Unlike simple deletion of a file ( Delete or Delete from the context menu), this refactoring makes sure that you do not delete files that are referenced in your source code. Select the Search for references checkbox to update the references to the moved file or folder. Choose an existing folder or type the name of a new one to be created. In the dialog that opens, specify the new parent folder. In the Project tool window, select the file or folder to move and choose Refactor | Move from the context menu or press F6. Click Do Refactor when you are happy with the expected results. Note that regardless of the options selected, the search scope (places where you search for the name occurrences) is always limited to the current entity (for example, a file, or a class) and the entities that the current one depends on.Ĭlick Refactor and examine the suggested changes in the dedicated tab of the Find tool window, as described in Previewing, adjusting, and applying the suggested changes above. The usages are assigned to different categories which correspond to the options which you can turn on and off. If found, the changes you are making to the file name can also be applied to these usages. In addition to renaming the file itself, WebStorm can also look for the usages of the file name. To update the references to the file or folder in comments, strings, and text (for files), select the corresponding checkboxes. In the dialog that opens, type the new name of the file or folder. In the Project tool window, select the file or folder to rename and choose Refactor | Rename from the context menu or press Shift+F6. To open a file, directory or package automatically after it is copied, select the Open copy in editor checkbox. In the dialog that opens, specify the new name of the file or the folder and the new parent folder, if applicable. Select the file or folder to copy in the Project tool window and press F5 or select Refactor | Copy from the context menu or from the main menu.Īlternatively, select the file or the folder to copy in the Project tool window and drag it to the new folder with the Control key pressed. Refactorings for files and folders are available in all types of applications. With these refactorings you can make copies of files and folders with the same names or with new ones, store them in the same parent folders or in new ones, as well as move files and folders to other locations. When you are happy with the proposed results, click Do Refactor.Ĭopying, renaming, and moving files and folders WebStorm shows all conflicting entries on the Conflicts tab in the Find tool window, enabling you to navigate to the problematic lines of code and to make the necessary fixes.Ĭancel the refactoring and return to the editor. Preview the conflicts by clicking the Show in View button. As a result, the refactoring will be performed, however, this may lead to erroneous results. Ignore the conflicts by clicking the Continue button. If any conflicts are expected after the refactoring, WebStorm displays a dialog with a brief description of the encountered problems. If necessary, some changes can be excluded during refactoring. WebStorm opens a dedicated tab in the Find tool window and shows the changes that are going to be made. To preview the potential changes and make the necessary adjustments, click Preview in the refactoring-specific dialog. Previewing, adjusting, and applying the suggested changesįor some refactorings WebStorm provides an option to preview the changes before applying them. Open the Refactor This list (choose Refactor | Refactor This or press Control+Alt+Shift+T), and then choose the required refactoring. Press the dedicated shortcut (refer to the table of available refactorings below). In the editor, select the expression or symbol to refactor.įrom the main menu or from the context menu of the selection, choose Refactor |. In the Project tool window, select the file or folder to move, copy, or rename. Below is an overview of these main steps you will perform when refactoring your code. Refactoring source code: main stepsĭespite the differences in the goals and the workflow, all the WebStorm refactorings require some mandatory steps. WebStorm offers a wide variety of code refactorings, which track down and correct the affected code references automatically. Refactoring helps you keep your code solid, dry, and easy to maintain. Refactoring means updating the source code without changing the behaviour of the application.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |