Skip to content

Commit

Permalink
Fix no comment handling in enum [jdl]
Browse files Browse the repository at this point in the history
  • Loading branch information
swarajsaaj committed Aug 8, 2021
1 parent 99e7d31 commit 733070a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions generators/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,19 +591,23 @@ function getEnums(enums, customValuesState, comments) {
return enums.map(enumValue => ({
name: enumValue,
value: enumValue,
comment: comments[enumValue] && getJavadoc(comments[enumValue], 0),
comment: comments && comments[enumValue] && getJavadoc(comments[enumValue], 0),
}));
}
return enums.map(enumValue => {
if (!doesTheEnumValueHaveACustomValue(enumValue)) {
return { name: enumValue.trim(), value: enumValue.trim(), comment: comments[enumValue] && getJavadoc(comments[enumValue], 0) };
return {
name: enumValue.trim(),
value: enumValue.trim(),
comment: comments && comments[enumValue] && getJavadoc(comments[enumValue], 0),
};
}
// eslint-disable-next-line no-unused-vars
const matched = /\s*(.+?)\s*\((.+?)\)/.exec(enumValue);
return {
name: matched[1],
value: matched[2],
comment: comments[matched[1]] && getJavadoc(comments[matched[1]], 0),
comment: comments && comments[matched[1]] && getJavadoc(comments[matched[1]], 0),
};
});
}
Expand Down

0 comments on commit 733070a

Please sign in to comment.