Skip to content

Commit

Permalink
Ignore javadoc copy errors for constructors
Browse files Browse the repository at this point in the history
Lombok should not crash if it cannot copy or generate javadoc for
generated code. We have already added this try...catch to all other
javadoc copy methods.
  • Loading branch information
Rawi01 committed Aug 20, 2024
1 parent f19a7e8 commit b960d0d
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions src/core/lombok/eclipse/handlers/HandleConstructor.java
Original file line number Diff line number Diff line change
Expand Up @@ -588,25 +588,27 @@ public MethodDeclaration createStaticConstructor(AccessLevel level, String name,
}

private void generateConstructorJavadoc(EclipseNode typeNode, EclipseNode constructorNode, Collection<EclipseNode> fields) {
if (fields.isEmpty()) return;

String constructorJavadoc = getConstructorJavadocHeader(typeNode.getName());
boolean fieldDescriptionAdded = false;
for (EclipseNode fieldNode : fields) {
String paramName = String.valueOf(removePrefixFromField(fieldNode));
String fieldJavadoc = getDocComment(fieldNode);
String paramJavadoc = getConstructorParameterJavadoc(paramName, fieldJavadoc);

if (paramJavadoc == null) {
paramJavadoc = "@param " + paramName;
} else {
fieldDescriptionAdded = true;
try {
if (fields.isEmpty()) return;

String constructorJavadoc = getConstructorJavadocHeader(typeNode.getName());
boolean fieldDescriptionAdded = false;
for (EclipseNode fieldNode : fields) {
String paramName = String.valueOf(removePrefixFromField(fieldNode));
String fieldJavadoc = getDocComment(fieldNode);
String paramJavadoc = getConstructorParameterJavadoc(paramName, fieldJavadoc);

if (paramJavadoc == null) {
paramJavadoc = "@param " + paramName;
} else {
fieldDescriptionAdded = true;
}

constructorJavadoc = addJavadocLine(constructorJavadoc, paramJavadoc);
}

constructorJavadoc = addJavadocLine(constructorJavadoc, paramJavadoc);
}
if (fieldDescriptionAdded) {
setDocComment(typeNode, constructorNode, constructorJavadoc);
}
if (fieldDescriptionAdded) {
setDocComment(typeNode, constructorNode, constructorJavadoc);
}
} catch (Exception ignore) {}
}
}

0 comments on commit b960d0d

Please sign in to comment.