The Safe Delete refactoring also builds on the same Find Usages framework as Rename.
In addition to that, in order to support Safe Delete, a plugin needs to implement two things:
The RefactoringSupportProvider interface, registered in the
com.intellij.lang.refactoringSupportextension point, and theisSafeDeleteAvailable()method, which checks if theSafe Deleterefactoring is available for a specific PSI elementThe PsiElement.delete() method for the PsiElement subclasses for which
Safe Deleteis available. Deleting PSI elements is implemented by deleting the underlying AST nodes from the AST tree (which, in turn, causes the text ranges corresponding to the AST nodes to be deleted from the document).
Example: delete() implementation for a Property language plugin
If needed, it's possible to further customize how Safe Delete is performed for a particular type of element (how references are searched, etc).
This is done by implementing the SafeDeleteProcessorDelegate interface.
Example: SafeDeleteProcessorDelegate implementation for Properties language plugin