boolean (@NotNull Ref<UsageInfo[]> refUsages) { UsageInfo[] usages = refUsages.get(); List<String> conflicts = new ArrayList<>(); for (PsiElement element : myElements) { for (SafeDeleteProcessorDelegate delegate : SafeDeleteProcessorDelegate.EP_NAME.getExtensionList()) { if (delegate.handlesElement(element)) { Collection<String> foundConflicts = delegate instanceof SafeDeleteProcessorDelegateBase ? ((SafeDeleteProcessorDelegateBase)delegate).findConflicts(element, myElements, usages) : delegate.findConflicts(element, myElements); if (foundConflicts != null) { conflicts.addAll(foundConflicts); } break; } } } if (checkConflicts(usages, conflicts)) return false; UsageInfo[] preprocessedUsages = usages; for (SafeDeleteProcessorDelegate delegate: SafeDeleteProcessorDelegate.EP_NAME.getExtensionList()) { preprocessedUsages = delegate.preprocessUsages(myProject, preprocessedUsages); if (preprocessedUsages == null) return false; } HashSet<UsageInfo> diff = ContainerUtil.newHashSet(preprocessedUsages); diff.removeAll(Arrays.asList(usages)); if (checkConflicts(diff.toArray(UsageInfo.EMPTY_ARRAY), new ArrayList<>())) return false; UsageInfo[] filteredUsages = UsageViewUtil.removeDuplicatedUsages(preprocessedUsages); prepareSuccessful(); // dialog is always dismissed refUsages.set(filteredUsages); return true; }