Safe Delete Refactoring
The Safe Delete refactoring also builds on the same Find Usages framework as Rename Refactoring.
In addition to that, to support Safe Delete, a plugin needs to implement two things:
-
The
RefactoringSupportProvider
interface, registered in thecom.intellij.lang.refactoringSupport
extension point, and theisSafeDeleteAvailable()
method, which checks if the Safe Delete refactoring is available for a specific PSI element -
The
PsiElement.delete()
method for thePsiElement
subclasses for which Safe Delete is 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 in Properties language plugin
If needed, it's possible to further customize how Safe Delete is performed for a particular type of element (e.g., how references are searched) via SafeDeleteProcessorDelegate
.
Example:
SafeDeleteProcessorDelegate
implementation for Properties language plugin