@NotNull
  private static GrLightMethodBuilder generateFieldConstructor(@NotNull TransformationContext context,
                                                               @Nullable PsiAnnotation tupleConstructor,
                                                               boolean immutable,
                                                               boolean canonical,
                                                               @NotNull String originInfo) {
    final GrTypeDefinition typeDefinition = context.getCodeClass();
    final GrLightMethodBuilder fieldsConstructor = new GrLightMethodBuilder(typeDefinition.getManager(), typeDefinition.getName());
    fieldsConstructor.setConstructor(true);
    fieldsConstructor.setNavigationElement(typeDefinition);
    fieldsConstructor.setContainingClass(typeDefinition);

    if (canonical) {
      var modifierList = typeDefinition.getModifierList();
      if (modifierList != null) {
        tupleConstructor =
          new GrLightAnnotation(modifierList, typeDefinition, GroovyCommonClassNames.GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR, Map.of());
      }
    }
    if (immutable) {
      var modifierList = typeDefinition.getModifierList();
      if (modifierList != null) {
        tupleConstructor = new GrLightAnnotation(modifierList, typeDefinition, GroovyCommonClassNames.GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR, Map.of(TupleConstructorAttributes.DEFAULTS, "false"));
      }
    }

    if (tupleConstructor != null) {
      boolean optional = !immutable && PsiUtil.getAnnoAttributeValue(tupleConstructor, TupleConstructorAttributes.DEFAULTS, true);
      Visibility visibility = getVisibility(tupleConstructor, fieldsConstructor, Visibility.PUBLIC);
      fieldsConstructor.addModifier(visibility.toString());
      AffectedMembersCache cache = GrGeneratedConstructorUtils.getAffectedMembersCache(tupleConstructor);

      checkContainingClass(context, fieldsConstructor);

      for (PsiNamedElement element : cache.getAffectedMembers()) {
        GrLightParameter parameter;
        if (element instanceof PsiField) {
          String name = AffectedMembersCache.getExternalName(element);
          parameter = new GrLightParameter(name == null ? "arg" : name, ((PsiField)element).getType(), fieldsConstructor);
        } else if (element instanceof GrMethod) {
          String name = PropertyUtilBase.getPropertyName((PsiMember)element);
          PsiType type = PropertyUtilBase.getPropertyType((PsiMethod)element);
          parameter = new GrLightParameter(name == null ? "arg" : name, type, fieldsConstructor);
        } else {
          parameter = null;
        }
        if (parameter != null) {
          parameter.setOptional(optional);
          fieldsConstructor.addParameter(parameter);
        }
      }
    }
    fieldsConstructor.setOriginInfo(originInfo);
    return fieldsConstructor;
  }
@NotNull
  private static GrLightMethodBuilder generateFieldConstructor(@NotNull TransformationContext context,
                                                               @Nullable PsiAnnotation tupleConstructor,
                                                               boolean immutable,
                                                               boolean canonical,
                                                               @NotNull String originInfo)