void (final PsiClass aClass, final String overloadName, final PsiElement extractedFragment, final Map<PsiMethodCallExpression, PsiMethod> ret) { final PsiMethod[] overloads = aClass.findMethodsByName(overloadName, false); for (final PsiMethod overload : overloads) { for (final PsiReference ref : ReferencesSearch.search(overload)) { final PsiElement element = ref.getElement(); final PsiElement parent = element.getParent(); if (parent instanceof PsiMethodCallExpression call) { if (PsiTreeUtil.isAncestor(extractedFragment, element, false)) { call.putCopyableUserData(RESOLVE_TARGET_KEY, overload); } else { //we assume element won't be invalidated as a result of extraction ret.put(call, overload); } } } } }