aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-07-08 21:17:01 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-07-08 21:21:33 +0200
commite7ff097fec867714b8a064b559dfc9e5162a489c (patch)
treef0856faea39984215db942113753fd5b8ac15766 /src/core/lombok/javac
parentbf8e2afed07b4062ac3d3fee8b2f8981d1213f7e (diff)
downloadlombok-e7ff097fec867714b8a064b559dfc9e5162a489c.tar.gz
lombok-e7ff097fec867714b8a064b559dfc9e5162a489c.tar.bz2
lombok-e7ff097fec867714b8a064b559dfc9e5162a489c.zip
Fixed value's snippet integration (it hadn't been updated yet now that Value has moved from experimental into core).
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/HandleWither.java5
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java27
2 files changed, 22 insertions, 10 deletions
diff --git a/src/core/lombok/javac/handlers/HandleWither.java b/src/core/lombok/javac/handlers/HandleWither.java
index ba5aa72d..b3f218b8 100644
--- a/src/core/lombok/javac/handlers/HandleWither.java
+++ b/src/core/lombok/javac/handlers/HandleWither.java
@@ -33,6 +33,7 @@ import lombok.core.TransformationsUtil;
import lombok.experimental.Wither;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
+import lombok.javac.handlers.JavacHandlerUtil.CopyJavadoc;
import lombok.javac.handlers.JavacHandlerUtil.FieldAccess;
import org.mangosdk.spi.ProviderFor;
@@ -264,7 +265,9 @@ public class HandleWither extends JavacAnnotationHandler<Wither> {
if (isFieldDeprecated(field)) {
annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(chainDots(field, "java", "lang", "Deprecated"), List.<JCExpression>nil()));
}
- return recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, returnType,
+ JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, returnType,
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
+ copyJavadoc(field, decl, CopyJavadoc.WITHER);
+ return decl;
}
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 6aed5508..a24dad7d 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1165,7 +1165,7 @@ public class JavacHandlerUtil {
return (JCExpression) in;
}
- private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
+ private static final Pattern SECTION_FINDER = Pattern.compile("^\\s*\\**\\s*[-*][-*]+\\s*([GS]ETTER|WITHER)\\s*[-*][-*]+\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
private static String stripLinesWithTagFromJavadoc(String javadoc, String regexpFragment) {
Pattern p = Pattern.compile("^\\s*\\**\\s*" + regexpFragment + "\\s*\\**\\s*$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
@@ -1213,17 +1213,26 @@ public class JavacHandlerUtil {
},
SETTER {
@Override public String[] split(String javadoc) {
- // step 1: Check if there is a 'SETTER' section. If yes, that becomes the new one and we strip that from the original.
- String[] out = splitJavadocOnSectionIfPresent(javadoc, "SETTER");
- if (out != null) return out;
- // failing that, create a copy, but strip @param from the original and @return from the copy.
- String copy = javadoc;
- javadoc = stripLinesWithTagFromJavadoc(javadoc, "@param(?:eter)?\\s+.*");
- copy = stripLinesWithTagFromJavadoc(copy, "@returns?\\s+.*");
- return new String[] {copy, javadoc};
+ return splitForSetters(javadoc, "SETTER");
+ }
+ },
+ WITHER {
+ @Override public String[] split(String javadoc) {
+ return splitForSetters(javadoc, "WITHER");
}
};
+ private static String[] splitForSetters(String javadoc, String sectionName) {
+ // step 1: Check if there is a 'SETTER' section. If yes, that becomes the new one and we strip that from the original.
+ String[] out = splitJavadocOnSectionIfPresent(javadoc, sectionName);
+ if (out != null) return out;
+ // failing that, create a copy, but strip @param from the original and @return from the copy.
+ String copy = javadoc;
+ javadoc = stripLinesWithTagFromJavadoc(javadoc, "@param(?:eter)?\\s+.*");
+ copy = stripLinesWithTagFromJavadoc(copy, "@returns?\\s+.*");
+ return new String[] {copy, javadoc};
+ }
+
/** Splits the javadoc into the section to be copied (ret[0]) and the section to replace the original with (ret[1]) */
public String[] split(String javadoc) {
return new String[] {javadoc, javadoc};