From b960d0d02a7c3ec9afae493011730345dd4ba6b0 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Tue, 20 Aug 2024 23:32:45 +0200 Subject: [PATCH] Ignore javadoc copy errors for constructors 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. --- .../eclipse/handlers/HandleConstructor.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 81b4cf1194..1941569670 100755 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -588,25 +588,27 @@ public MethodDeclaration createStaticConstructor(AccessLevel level, String name, } private void generateConstructorJavadoc(EclipseNode typeNode, EclipseNode constructorNode, Collection 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) {} } }