void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PyParameter psi = PyUtil.as(descriptor.getPsiElement(), PyParameter.class); assert psi != null; final PyCallableParameter parameter = PyCallableParameterImpl.psi(psi); final TypeEvalContext ctx = TypeEvalContext.codeAnalysis(project, psi.getContainingFile()); final PyFunction function = PsiTreeUtil.getParentOfType(psi, PyFunction.class); if (function != null) { final PyResolveContext resolveContext = PyResolveContext.defaultContext(ctx); StreamEx .of(PyPsiIndexUtil.findUsages(function, false)) .map(UsageInfo::getElement) .nonNull() .map(PsiElement::getParent) .select(PyCallExpression.class) .flatCollection(callExpression -> callExpression.multiMapArguments(resolveContext)) .flatCollection(mapping -> mapping.getMappedParameters().entrySet()) .filter(entry -> parameter.equals(entry.getValue())) .forEach(entry -> entry.getKey().delete()); final PyStringLiteralExpression docStringExpression = function.getDocStringExpression(); final String parameterName = parameter.getName(); if (docStringExpression != null && parameterName != null) { PyDocstringGenerator.forDocStringOwner(function).withoutParam(parameterName).buildAndInsert(); } if (parameterName != null) { StreamEx .of(PyiUtil.getOverloads(function, ctx)) .map(overload -> overload.getParameterList().getParameters()) .map(parameters -> ContainerUtil.find(parameters, overloadParameter -> parameterName.equals(overloadParameter.getName()))) .nonNull() .forEach(PsiElement::delete); } } psi.delete(); }