void () { final List<UsageInfo> foreignMethodUsages = new ArrayList<>(); final Runnable runnable = () -> { final Set<MemberNodeBase<PsiMethod>> nodes = getSelectedNodes(); for (MemberNodeBase<PsiMethod> node : nodes) { final SafeDeleteJavaMethodNode methodNode = (SafeDeleteJavaMethodNode)node; final PsiMethod nodeMethod = methodNode.getMember(); if (nodeMethod.equals(myMethod)) continue; int parameterIdx = methodNode.myParameterIdx; final PsiParameter parameter = nodeMethod.getParameterList().getParameters()[parameterIdx]; foreignMethodUsages.add(new SafeDeleteParameterCallHierarchyUsageInfo(nodeMethod, parameter, nodeMethod, parameter)); ReferencesSearch.search(nodeMethod).forEach(reference -> { final PsiElement element = reference.getElement(); JavaSafeDeleteDelegate safeDeleteDelegate = JavaSafeDeleteDelegate.EP.forLanguage(element.getLanguage()); if (safeDeleteDelegate != null) { safeDeleteDelegate.createUsageInfoForParameter(reference, foreignMethodUsages, parameter, parameterIdx, parameter.isVarArgs()); } return true; }); ReferencesSearch.search(parameter).forEach(reference -> { PsiElement element = reference.getElement(); final PsiDocTag docTag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class); if (docTag != null) { foreignMethodUsages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(docTag, parameter, true)); } return true; }); } }; if (ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ApplicationManager.getApplication().runReadAction(runnable), JavaRefactoringBundle.message( "safe.delete.search.for.caller.method.usages.progress"), true, myProject)) { myResult.addAll(foreignMethodUsages); } super.doOKAction(); }