@Contract(pure = true)
  public static boolean isUsedAsSuperConstructorCallArgument(@NotNull PsiParameter parameter, boolean superMustBeLibrary) {
    final PsiElement scope = parameter.getDeclarationScope();
    if (!(scope instanceof PsiMethod method) || !((PsiMethod)scope).isConstructor()) {
      return false;
    }
    final Set<PsiMethod> checked = new HashSet<>();

    while (true) {
      ProgressManager.checkCanceled();
      if (!checked.add(method)) {
        // we've already seen this method -> circular call chain
        return false;
      }
      final PsiMethodCallExpression call = JavaPsiConstructorUtil.findThisOrSuperCallInConstructor(method);
      if (call == null) {
        return false;
      }
      final int index = getParameterReferenceIndex(call, parameter);
      if (index < 0) {
        return false;
      }
      final JavaResolveResult resolveResult = call.resolveMethodGenerics();
      if (!resolveResult.isValidResult()) {
        return false;
      }
      method = (PsiMethod)resolveResult.getElement();
      if (method == null) {
        return false;
      }
      if (JavaPsiConstructorUtil.isSuperConstructorCall(call) && (!superMustBeLibrary || method instanceof PsiCompiledElement)) {
        return true;
      }
      final PsiParameter[] parameters = method.getParameterList().getParameters();
      parameter = parameters[Math.min(index, parameters.length - 1)];
    }
  }
@Contract(pure = true)
  public static boolean isUsedAsSuperConstructorCallArgument(@NotNull PsiParameter parameter, boolean superMustBeLibrary)