IntelliJ IDEA 13.1.0 Web Help

The Safe Delete refactoring allows you to safely remove the following symbols from the code:

  • Class
  • Method
  • Field
  • Interface
  • Parameter

IntelliJ IDEA checks for the remaining usages of the deleted symbol. The refactoring allows you to make the necessary corrections of the code before the symbol is actually deleted. The procedure of removing a symbol slightly differs depending on the type of the symbol to be deleted.


This refactoring is also available from UML Class diagram.

To safely delete a symbol
  1. Select the symbol to be deleted.
  2. Choose Refactor | Safe Delete on the main menu or in the context menu of the selection. Alternatively, press .


    You can also press or , or , or , or in the Project tool window. Then you can either perform a Safe Delete or simply delete the symbol.

  3. In the Safe Delete dialog box that opens, specify additional settings for the refactoring:
    • To have the changes applied to comments and strings, select the Search in comments and strings check box.
    • To have the changes applied to text files (such as documentation, HTML, JSP and other files included in your project), select the Search for text occurrences check box.
  4. Click OK to continue. If no usages of the symbol are found, the refactoring removes the symbol. If IntelliJ IDEA finds any occurrences of the symbol in the code, the Usages Detected dialog box appears.
  5. In the Usages Detected dialog box, do one of the following:
    • To proceed with refactoring and delete the symbol, click the Ignore button, leaving all the usages of the symbol intact. In this case, to make your code compilable, you have to manually inspect the code and make the necessary corrections.
    • To view the list of direct usages of the symbol, click the View usages button. IntelliJ IDEA stops the refactoring procedure and the displays a list of direct usages of the selected symbol in the Find tool window. Navigate to each usage location and manually correct the code. When ready, click the Rerun Safe Delete button to invoke the refactoring again.

See Also


Web Resources: