Remove duplicate content in copied @param tags

This commit is contained in:
Rawi01 committed 2024-06-15 11:32:51 +02:00
1 parent 26c8271b3e
commit a2dd5ffa6a
5 files changed
+20 -13

No files matched your search

+14 -7
View File
@@ -910,9 +910,13 @@ public class HandlerUtil {
}
}
public static String stripLinesWithTagFromJavadoc(String javadoc, JavadocTag tag) {
public static String stripLinesWithTagFromJavadoc(String javadoc, JavadocTag... tags) {
if (javadoc == null || javadoc.isEmpty()) return javadoc;
return tag.pattern.matcher(javadoc).replaceAll("").trim();
String result = javadoc;
for (JavadocTag tag : tags) {
result = tag.pattern.matcher(result).replaceAll("").trim();
}
return result;
}
public static String stripSectionsFromJavadoc(String javadoc) {
@@ -968,7 +972,7 @@ public class HandlerUtil {
public static String addJavadocLine(String in, String line) {
if (in == null) return line;
if (in.endsWith("\n")) return in + line + "\n";
if (in.endsWith("\n")) return in + line;
return in + "\n" + line;
}
@@ -990,11 +994,14 @@ public class HandlerUtil {
String fieldBaseJavadoc = stripSectionsFromJavadoc(fieldJavadoc);
String paramJavadoc = getParamJavadoc(fieldBaseJavadoc, paramName);
if (paramJavadoc == null) {
paramJavadoc = stripLinesWithTagFromJavadoc(fieldBaseJavadoc, JavadocTag.PARAM);
paramJavadoc = stripLinesWithTagFromJavadoc(paramJavadoc, JavadocTag.RETURN);
if (paramJavadoc != null) {
return paramJavadoc;
}
return paramJavadoc;
String javadocWithoutTags = stripLinesWithTagFromJavadoc(fieldBaseJavadoc, JavadocTag.PARAM, JavadocTag.RETURN);
if (javadocWithoutTags != null) {
return "@param " + paramName + " " + javadocWithoutTags;
}
return null;
}
}
@@ -598,12 +598,12 @@ public class HandleConstructor {
String paramJavadoc = getConstructorParameterJavadoc(paramName, fieldJavadoc);
if (paramJavadoc == null) {
paramJavadoc = "";
paramJavadoc = "@param " + paramName;
} else {
fieldDescriptionAdded = true;
}
constructorJavadoc = addJavadocLine(constructorJavadoc, "@param " + paramName + " " + paramJavadoc);
constructorJavadoc = addJavadocLine(constructorJavadoc, paramJavadoc);
}
if (fieldDescriptionAdded) {
setDocComment(typeNode, constructorNode, constructorJavadoc);
@@ -490,12 +490,12 @@ public class HandleConstructor {
String paramJavadoc = getConstructorParameterJavadoc(paramName, fieldJavadoc);
if (paramJavadoc == null) {
paramJavadoc = "";
paramJavadoc = "@param " + paramName;
} else {
fieldDescriptionAdded = true;
}
constructorJavadoc = addJavadocLine(constructorJavadoc, "@param " + paramName + " " + paramJavadoc);
constructorJavadoc = addJavadocLine(constructorJavadoc, paramJavadoc);
}
if (fieldDescriptionAdded) {
setDocComment(cu, constructor, constructorJavadoc);
@@ -16,7 +16,7 @@ public class ConstructorJavadoc {
/**
* Creates a new {@code ConstructorJavadoc} instance.
*
* @param fieldName Some text
* @param fieldName Hello, World1
* @param fieldName2 Sky is blue
*/
@java.lang.SuppressWarnings("all")
@@ -5,7 +5,7 @@ public @AllArgsConstructor class ConstructorJavadoc {
/**
* Creates a new {@code ConstructorJavadoc} instance.
*
* @param fieldName Some text
* @param fieldName Hello, World1
* @param fieldName2 Sky is blue
*/
public @java.lang.SuppressWarnings("all") @lombok.Generated ConstructorJavadoc(final int fieldName, final int fieldName2) {