ModCommand (ActionContext context, List<PsiField> fields, List<PsiMethod> constructors) { return ModCommand.psiUpdate(context, updater -> { List<PsiField> writableFields = ContainerUtil.map(fields, updater::getWritable); PsiClass psiClass = writableFields.get(0).getContainingClass(); if (psiClass == null) return; List<PsiMethod> writableConstructors; if (constructors.isEmpty()) { writableConstructors = List.of(AddDefaultConstructorFix.addDefaultConstructor(psiClass)); } else { writableConstructors = ContainerUtil.map(constructors, updater::getWritable); } for (PsiMethod constructor : writableConstructors) { updater.trackDeclaration(constructor); } Map<PsiMethod, ChainedConstructorData> data = ChainedConstructorData.getChainedConstructorDataMap(writableFields, writableConstructors); for (PsiMethod constructor : writableConstructors) { addParameterToConstructor(context, constructor, writableFields, updater, data.get(constructor)); } }); }