void (@NotNull final Project project, @NotNull final ProblemDescriptor descriptor) { final PsiElement element = descriptor.getPsiElement(); final PyFunction problemFunction = PsiTreeUtil.getParentOfType(element, PyFunction.class); if (problemFunction == null) return; final PyClass containingClass = problemFunction.getContainingClass(); if (containingClass == null) return; final List<PyReferenceExpression> usages = StreamEx.of(PyPsiIndexUtil.findUsages(problemFunction, false)) .map(UsageInfo::getElement) .select(PyReferenceExpression.class) .toList(); ApplicationManagerEx.getApplicationEx().runWriteActionWithCancellableProgressInDispatchThread( PyPsiBundle.message("refactoring.progress.title.updating.existing.usages"), problemFunction.getProject(), null, (indicator -> { PyFunction function = transformDefinition(problemFunction); for (int i = 0; i < usages.size(); i++) { indicator.checkCanceled(); indicator.setFraction((i + 1.0) / usages.size()); PyReferenceExpression usage = usages.get(i); PsiFile usageFile = usage.getContainingFile(); updateUsage(function, usage, usageFile, !usageFile.equals(containingClass.getContainingFile())); } }) ); }