Example:
<extensions defaultExtensionNs="com.intellij">
<refactoring.safeDeleteProcessor implementation="...CustomDeleteProcessor"/>
</extensions>
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiField;
import com.intellij.refactoring.safeDelete.JavaSafeDeleteProcessor;
import com.intellij.refactoring.safeDelete.NonCodeUsageSearchInfo;
import com.intellij.usageView.UsageInfo;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class CustomJavaDeleteProcessor extends JavaSafeDeleteProcessor {
@Override
public boolean handlesElement(PsiElement element) {
return element instanceof PsiField;
}
@Override
public @Nullable NonCodeUsageSearchInfo findUsages(@NotNull PsiElement element, @NotNull PsiElement[] allElementsToDelete, @NotNull List<UsageInfo> usages) {
//some code
return super.findUsages(element, allElementsToDelete, usages);
}
}
If install plugin in ultimate IDE → code work.
If install plugin in community IDE→ code not work.
The documentation doesn’t say anything about the limitations of SafeDeleteProcessor implementations.