aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/JavacHandlerUtil.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-01-23 22:02:09 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-01-23 22:02:09 +0100
commit5782b909c5c0e8f766de36d600bc314eaa98e6b2 (patch)
treebb09d0d6f579e04f0a2a20381b5272401d7c713c /src/core/lombok/javac/handlers/JavacHandlerUtil.java
parent644e528564006b84c44526fb2b660754c16f335f (diff)
downloadlombok-5782b909c5c0e8f766de36d600bc314eaa98e6b2.tar.gz
lombok-5782b909c5c0e8f766de36d600bc314eaa98e6b2.tar.bz2
lombok-5782b909c5c0e8f766de36d600bc314eaa98e6b2.zip
[#585] Copying of javadoc to getters / setters / withers woudl copy non-relevant sections too.
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 80ba9405..bc4dda8e 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1294,6 +1294,13 @@ public class JavacHandlerUtil {
return m.replaceAll("");
}
+ public static String stripSectionsFromJavadoc(String javadoc) {
+ Matcher m = SECTION_FINDER.matcher(javadoc);
+ if (!m.find()) return javadoc;
+
+ return javadoc.substring(0, m.start());
+ }
+
public static String[] splitJavadocOnSectionIfPresent(String javadoc, String sectionName) {
Matcher m = SECTION_FINDER.matcher(javadoc);
int getterSectionHeaderStart = -1;
@@ -1320,15 +1327,17 @@ public class JavacHandlerUtil {
}
public static enum CopyJavadoc {
- VERBATIM, GETTER {
+ VERBATIM,
+ GETTER {
@Override public String[] split(String javadoc) {
// step 1: Check if there is a 'GETTER' section. If yes, that becomes the new method's javadoc and we strip that from the original.
String[] out = splitJavadocOnSectionIfPresent(javadoc, "GETTER");
if (out != null) return out;
- // failing that, create a copy, but strip @return from the original and @param from the copy.
+ // failing that, create a copy, but strip @return from the original and @param from the copy, as well as other sections.
String copy = javadoc;
javadoc = stripLinesWithTagFromJavadoc(javadoc, "@returns?\\s+.*");
copy = stripLinesWithTagFromJavadoc(copy, "@param(?:eter)?\\s+.*");
+ copy = stripSectionsFromJavadoc(copy);
return new String[] {copy, javadoc};
}
},
@@ -1351,6 +1360,7 @@ public class JavacHandlerUtil {
String copy = javadoc;
javadoc = stripLinesWithTagFromJavadoc(javadoc, "@param(?:eter)?\\s+.*");
copy = stripLinesWithTagFromJavadoc(copy, "@returns?\\s+.*");
+ copy = stripSectionsFromJavadoc(copy);
return new String[] {copy, javadoc};
}
@@ -1364,8 +1374,8 @@ public class JavacHandlerUtil {
* Copies javadoc on one node to the other.
*
* in 'GETTER' copyMode, first a 'GETTER' segment is searched for. If it exists, that will become the javadoc for the 'to' node, and this section is
- * stripped out of the 'from' node. If no 'GETTER' segment is found, then the entire javadoc is taken minus any {@code @param} lines. any {@code @return} lines
- * are stripped from 'from'.
+ * stripped out of the 'from' node. If no 'GETTER' segment is found, then the entire javadoc is taken minus any {@code @param} lines and other sections.
+ * any {@code @return} lines are stripped from 'from'.
*
* in 'SETTER' mode, stripping works similarly to 'GETTER' mode, except {@code param} are copied and stripped from the original and {@code @return} are skipped.
*/