@Contract("_, null -> null; _, !null -> !null")
  public static PsiMethod setVisibility(PsiMember member, PsiMethod prototype) {
    if (prototype == null) return null;

    PsiFile file = member.getContainingFile();
    JavaCodeStyleSettings javaSettings =
      file != null
      ? JavaCodeStyleSettings.getInstance(file)
      : CodeStyle.getProjectOrDefaultSettings(member.getProject()).getCustomSettings(JavaCodeStyleSettings.class);
    String visibility = javaSettings.VISIBILITY;

    @PsiModifier.ModifierConstant String newVisibility;
    final PsiClass containingClass = member.getContainingClass();
    if (VisibilityUtil.ESCALATE_VISIBILITY.equals(visibility)) {
      PsiClass aClass = member instanceof PsiClass ? (PsiClass)member : containingClass;
      newVisibility = PsiUtil.getSuitableModifierForMember(aClass, prototype.isConstructor());
    }
    else {
      newVisibility = (containingClass != null && containingClass.isRecord()) ? PsiModifier.PUBLIC : visibility;
    }
    VisibilityUtil.setVisibility(prototype.getModifierList(), newVisibility);

    return prototype;
  }
@Contract("_, null -> null; _, !null -> !null")
  public static PsiMethod setVisibility(PsiMember member, PsiMethod prototype)