private @IntentionName @NotNull String format(PsiVariable variable, PsiModifierList modifierList, boolean showContainingClass) {
    String name = null;
    PsiElement parent = variable != null ? variable : modifierList != null ? modifierList.getParent() : null;
    if (parent instanceof PsiClass psiClass) {
      name = psiClass.getName();
    }
    else if (parent instanceof PsiJavaModule module) {
      name = module.getName();
    }
    else if (parent instanceof PsiMethod method) {
      int options = PsiFormatUtilBase.SHOW_NAME | (showContainingClass ? PsiFormatUtilBase.SHOW_CONTAINING_CLASS : 0);
      name = PsiFormatUtil.formatMethod(method, PsiSubstitutor.EMPTY, options, 0);
    }
    else if (parent instanceof PsiVariable var) {
      int options = PsiFormatUtilBase.SHOW_NAME | (showContainingClass ? PsiFormatUtilBase.SHOW_CONTAINING_CLASS : 0);
      name = PsiFormatUtil.formatVariable(var, options, PsiSubstitutor.EMPTY);
    }
    else if (parent instanceof PsiClassInitializer initializer) {
      PsiClass containingClass = initializer.getContainingClass();
      String className = containingClass instanceof PsiAnonymousClass
                         ? QuickFixBundle.message("anonymous.class.presentation",
                                                  ((PsiAnonymousClass)containingClass).getBaseClassType().getPresentableText())
                         : containingClass != null ? containingClass.getName() : "unknown";
      name = QuickFixBundle.message("class.initializer.presentation", className);
    }
    else if (parent instanceof PsiRequiresStatement requiresStatement) {
      name = "requires " + requiresStatement.getModuleName();
    }

    String modifierText = VisibilityUtil.toPresentableText(myModifier);
    if (!myShouldHave && modifierList != null) {
      int count = 0;
      for (PsiElement child = modifierList.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child.getText().equals(myModifier)) count++;
      }
      if (count > 1) {
        return QuickFixBundle.message("remove.one.modifier.fix", modifierText);
      }
    }
    return QuickFixBundle.message(myShouldHave ? "add.modifier.fix" : "remove.modifier.fix", name, modifierText);
  }
private @IntentionName @NotNull String format(PsiVariable variable, PsiModifierList modifierList, boolean showContainingClass)