@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) {
      final PsiElement parent = element.getParent();
      if (!(parent instanceof PsiClass aClass)) {
        return;
      }
      final @NonNls StringBuilder methodText = new StringBuilder();
      final JavaCodeStyleSettings codeStyleSettings = JavaCodeStyleSettings.getInstance(aClass.getContainingFile());
      if (PsiUtil.isAvailable(JavaFeature.ANNOTATIONS, aClass) && codeStyleSettings.INSERT_OVERRIDE_ANNOTATION) {
        methodText.append("@java.lang.Override ");
      }
      final String className = aClass.getName();
      methodText.append("public ").append(className);
      final PsiTypeParameterList typeParameterList = aClass.getTypeParameterList();
      if (typeParameterList != null) {
        methodText.append(typeParameterList.getText());
      }
      methodText.append(" clone() {\n");
      if (myGenerateTryCatch) {
        methodText.append("try {\n");
      }
      if (aClass.getFields().length > 0) {
        if (codeStyleSettings.GENERATE_FINAL_LOCALS) {
          methodText.append("final ");
        }
        methodText.append(className).append(" clone = (").append(className).append(") super.clone();\n");
        methodText.append("  // ").append(InspectionGadgetsBundle.message("cloneable.class.without.clone.todo.message"));
        methodText.append("\nreturn clone;\n");
      }
      else {
        methodText.append("return (").append(className).append(") super.clone();\n");
      }
      if (myGenerateTryCatch) {
        methodText.append("""
                            } catch (CloneNotSupportedException e) {
                            throw new AssertionError();
                            }
                            """);
      }
      methodText.append("}");
      final PsiMethod method = JavaPsiFacade.getElementFactory(project).createMethodFromText(methodText.toString(), element);
      final PsiElement newElement = parent.add(method);
      GenerateMembersUtil.positionCaret(updater, newElement, true);
    }
@Override
    protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater)