diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-07-16 00:51:31 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2013-07-16 00:51:31 +0200 |
commit | 7af9add9996f2efab6cccc50c5503b3457534930 (patch) | |
tree | bd224bd341da31e1b5aba5e718f43b6fd1227e8d /src/core/lombok/javac/handlers/JavacHandlerUtil.java | |
parent | ec0cc4348cf71d872b796d0733fb64fc576ef5df (diff) | |
download | lombok-7af9add9996f2efab6cccc50c5503b3457534930.tar.gz lombok-7af9add9996f2efab6cccc50c5503b3457534930.tar.bz2 lombok-7af9add9996f2efab6cccc50c5503b3457534930.zip |
* Fixed issues with @FieldDefaults and @Value (you can NOT override
@Value's final-by-default and private-by-default with it; now
appropriate warnings are emitted)
* Builder now errors out on presence of most lombok annotations on an
explicit builder class.
* Builder now takes @FieldDefaults/@Value into account.
* Builder on type now generates the constructor as package private
instead of private to avoid synthetic accessor constructors.
* added a bunch of test cases.
* added a test case feature: If the expected file is omitted entirely
but there are expected messages, the differences in the output itself
are ignored.
* streamlined checking for boolean-ness (removed some duplicate code)
* added 'fluent' and 'chain' to @Builder.
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index a24dad7d..d7d29da2 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -21,6 +21,7 @@ */ package lombok.javac.handlers; +import static lombok.core.TransformationsUtil.INVALID_ON_BUILDERS; import static lombok.javac.Javac.*; import java.lang.annotation.Annotation; @@ -446,8 +447,12 @@ public class JavacHandlerUtil { } } - private static boolean isBoolean(JavacNode field) { + public static boolean isBoolean(JavacNode field) { JCExpression varType = ((JCVariableDecl) field.get()).vartype; + return isBoolean(varType); + } + + public static boolean isBoolean(JCExpression varType) { return varType != null && varType.toString().equals("boolean"); } @@ -1065,6 +1070,28 @@ public class JavacHandlerUtil { return maker.Ident(typeName); } + public static void sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(JavacNode typeNode, JavacNode errorNode) { + List<String> disallowed = List.nil(); + for (JavacNode child : typeNode.down()) { + for (Class<? extends java.lang.annotation.Annotation> annType : INVALID_ON_BUILDERS) { + if (annotationTypeMatches(annType, child)) { + disallowed = disallowed.append(annType.getSimpleName()); + } + } + } + + int size = disallowed.size(); + if (size == 0) return; + if (size == 1) { + errorNode.addError("@" + disallowed.head + " is not allowed on builder classes."); + return; + } + StringBuilder out = new StringBuilder(); + for (String a : disallowed) out.append("@").append(a).append(", "); + out.setLength(out.length() - 2); + errorNode.addError(out.append(" are not allowed on builder classes.").toString()); + } + static List<JCAnnotation> copyAnnotations(List<? extends JCExpression> in) { ListBuffer<JCAnnotation> out = ListBuffer.lb(); for (JCExpression expr : in) { |