diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/AllArgsConstructor.java | 14 | ||||
-rw-r--r-- | src/core/lombok/Getter.java | 15 | ||||
-rw-r--r-- | src/core/lombok/NoArgsConstructor.java | 14 | ||||
-rw-r--r-- | src/core/lombok/RequiredArgsConstructor.java | 14 | ||||
-rw-r--r-- | src/core/lombok/Setter.java | 21 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleConstructor.java | 18 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleGetter.java | 18 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleSetter.java | 31 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleConstructor.java | 20 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleGetter.java | 22 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSetter.java | 30 |
11 files changed, 54 insertions, 163 deletions
diff --git a/src/core/lombok/AllArgsConstructor.java b/src/core/lombok/AllArgsConstructor.java index 6c6319aa..f0e0e3ff 100644 --- a/src/core/lombok/AllArgsConstructor.java +++ b/src/core/lombok/AllArgsConstructor.java @@ -59,18 +59,4 @@ public @interface AllArgsConstructor { */ @Deprecated boolean suppressConstructorProperties() default false; - - /** - * If you want your constructor to have additional annotations, you can specify them here. - */ - AnyAnnotation[] onConstructor() default {}; - - /** - * Placeholder annotation to enable the placement of annotations on the constructor. - * @deprecated Don't use this annotation, since we might remove it. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} } diff --git a/src/core/lombok/Getter.java b/src/core/lombok/Getter.java index c42277b1..485f8cf0 100644 --- a/src/core/lombok/Getter.java +++ b/src/core/lombok/Getter.java @@ -59,20 +59,5 @@ public @interface Getter { */ lombok.AccessLevel value() default lombok.AccessLevel.PUBLIC; - /** - * If you want your getter method to have additional annotations, you can specify them here.<br/> - * If the {@code @Getter} is put on a type, {@code onMethod} may not be specified. - */ - AnyAnnotation[] onMethod() default {}; - boolean lazy() default false; - - /** - * Placeholder annotation to enable the placement of annotations on the getter method. - * @deprecated Don't use this annotation, since we might remove it. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} } diff --git a/src/core/lombok/NoArgsConstructor.java b/src/core/lombok/NoArgsConstructor.java index 9b8544ac..1a885b6f 100644 --- a/src/core/lombok/NoArgsConstructor.java +++ b/src/core/lombok/NoArgsConstructor.java @@ -51,18 +51,4 @@ public @interface NoArgsConstructor { * Sets the access level of the constructor. By default, generated constructors are {@code public}. */ AccessLevel access() default lombok.AccessLevel.PUBLIC; - - /** - * If you want your constructor to have additional annotations, you can specify them here. - */ - AnyAnnotation[] onConstructor() default {}; - - /** - * Placeholder annotation to enable the placement of annotations on the constructor. - * @deprecated Don't use this annotation, since we might remove it. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} } diff --git a/src/core/lombok/RequiredArgsConstructor.java b/src/core/lombok/RequiredArgsConstructor.java index 91879d82..ba567268 100644 --- a/src/core/lombok/RequiredArgsConstructor.java +++ b/src/core/lombok/RequiredArgsConstructor.java @@ -59,18 +59,4 @@ public @interface RequiredArgsConstructor { */ @Deprecated boolean suppressConstructorProperties() default false; - - /** - * If you want your constructor to have additional annotations, you can specify them here. - */ - AnyAnnotation[] onConstructor() default {}; - - /** - * Placeholder annotation to enable the placement of annotations on the constructor. - * @deprecated Don't use this annotation, since we might remove it. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} } diff --git a/src/core/lombok/Setter.java b/src/core/lombok/Setter.java index 107760a7..c13385d5 100644 --- a/src/core/lombok/Setter.java +++ b/src/core/lombok/Setter.java @@ -55,25 +55,4 @@ public @interface Setter { * If you want your setter to be non-public, you can specify an alternate access level here. */ lombok.AccessLevel value() default lombok.AccessLevel.PUBLIC; - - /** - * If you want your setter method to have additional annotations, you can specify them here. - * If the {@code @Setter} is put on a type, {@code onMethod} may not be specified. - */ - AnyAnnotation[] onMethod() default {}; - - /** - * If you want the parameter of your setter to have additional annotations, you can specify them here. - * If the {@code @Setter} is put on a type, {@code onParam} may not be specified. - */ - AnyAnnotation[] onParam() default {}; - - /** - * Placeholder annotation to enable the placement of annotations on the setter method or its parameter. - * @deprecated Don't use this annotation, since we might remove it. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} }
\ No newline at end of file diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 781e8dae..9af7a48c 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -81,8 +81,7 @@ public class HandleConstructor { String staticName = ann.staticName(); if (level == AccessLevel.NONE) return; List<EclipseNode> fields = new ArrayList<EclipseNode>(); - Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, onConstructor, false, false, ast); + new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, false, false, ast); } } @@ -97,8 +96,7 @@ public class HandleConstructor { @SuppressWarnings("deprecation") boolean suppressConstructorProperties = ann.suppressConstructorProperties(); if (level == AccessLevel.NONE) return; - Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, onConstructor, false, suppressConstructorProperties, ast); + new HandleConstructor().generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, false, suppressConstructorProperties, ast); } } @@ -137,8 +135,7 @@ public class HandleConstructor { fields.add(child); } - Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, onConstructor, false, suppressConstructorProperties, ast); + new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, false, suppressConstructorProperties, ast); } } @@ -157,10 +154,10 @@ public class HandleConstructor { } public void generateRequiredArgsConstructor(EclipseNode typeNode, AccessLevel level, String staticName, boolean skipIfConstructorExists, ASTNode source) { - generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, null, skipIfConstructorExists, false, source); + generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, skipIfConstructorExists, false, source); } - public void generateConstructor(EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, String staticName, Annotation[] onConstructor, boolean skipIfConstructorExists, boolean suppressConstructorProperties, ASTNode source) { + public void generateConstructor(EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, String staticName, boolean skipIfConstructorExists, boolean suppressConstructorProperties, ASTNode source) { if (skipIfConstructorExists && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return; if (skipIfConstructorExists) { for (EclipseNode child : typeNode.down()) { @@ -175,7 +172,7 @@ public class HandleConstructor { boolean staticConstrRequired = staticName != null && !staticName.equals(""); - ConstructorDeclaration constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fields, suppressConstructorProperties, onConstructor, source); + ConstructorDeclaration constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fields, suppressConstructorProperties, source); injectMethod(typeNode, constr); if (staticConstrRequired) { MethodDeclaration staticConstr = createStaticConstructor(level, staticName, typeNode, fields, source); @@ -218,7 +215,7 @@ public class HandleConstructor { } private ConstructorDeclaration createConstructor(AccessLevel level, - EclipseNode type, Collection<EclipseNode> fields, boolean suppressConstructorProperties, Annotation[] onConstructor, ASTNode source) { + EclipseNode type, Collection<EclipseNode> fields, boolean suppressConstructorProperties, ASTNode source) { long p = (long)source.sourceStart << 32 | source.sourceEnd; boolean isEnum = (((TypeDeclaration)type.get()).modifiers & ClassFileConstants.AccEnum) != 0; @@ -230,7 +227,6 @@ public class HandleConstructor { Eclipse.setGeneratedBy(constructor, source); constructor.modifiers = EclipseHandlerUtil.toEclipseModifier(level); - constructor.annotations = onConstructor; constructor.selector = ((TypeDeclaration)type.get()).name; constructor.constructorCall = new ExplicitConstructorCall(ExplicitConstructorCall.ImplicitSuper); Eclipse.setGeneratedBy(constructor.constructorCall, source); diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 88b24f8c..7dec8550 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -95,7 +95,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } for (EclipseNode field : typeNode.down()) { - if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, pos.get(), level, null, false); + if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, pos.get(), level, false); } return true; } @@ -118,7 +118,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { * If not, the getter is still generated if it isn't already there, though there will not * be a warning if its already there. The default access level is used. */ - public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, Annotation[] onMethod, boolean lazy) { + public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy) { for (EclipseNode child : fieldNode.down()) { if (child.getKind() == Kind.ANNOTATION) { if (annotationTypeMatches(Getter.class, child)) { @@ -128,7 +128,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } } - createGetterForField(level, fieldNode, fieldNode, pos, false, onMethod, lazy); + createGetterForField(level, fieldNode, fieldNode, pos, false, lazy); } public void handle(AnnotationValues<Getter> annotation, Annotation ast, EclipseNode annotationNode) { @@ -145,27 +145,25 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { if (node == null) return; - Annotation[] onMethod = getAndRemoveAnnotationParameter(ast, "onMethod"); switch (node.getKind()) { case FIELD: - createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, lazy); + createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, lazy); break; case TYPE: - if (onMethod != null && onMethod.length != 0) annotationNode.addError("'onMethod' is not supported for @Getter on a type."); if (lazy) annotationNode.addError("'lazy' is not supported for @Getter on a type."); generateGetterForType(node, annotationNode, level, false); break; } } - private void createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod, boolean lazy) { + private void createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy) { for (EclipseNode fieldNode : fieldNodes) { - createGetterForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, lazy); + createGetterForField(level, fieldNode, errorNode, source, whineIfExists, lazy); } } private void createGetterForField(AccessLevel level, - EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod, boolean lazy) { + EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, boolean lazy) { if (fieldNode.getKind() != Kind.FIELD) { errorNode.addError("@Getter is only supported on a class or a field."); return; @@ -209,7 +207,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } MethodDeclaration method = generateGetter((TypeDeclaration) fieldNode.up().get(), fieldNode, getterName, modifier, source, lazy); - Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN), onMethod); + Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN)); if (copiedAnnotations.length != 0) { method.annotations = copiedAnnotations; } diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java index 1f1ab628..5f684410 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.java @@ -58,7 +58,6 @@ import org.mangosdk.spi.ProviderFor; */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleSetter extends EclipseAnnotationHandler<Setter> { - private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0]; public boolean generateSetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelSetter) { if (checkForTypeLevelSetter) { if (typeNode != null) for (EclipseNode child : typeNode.down()) { @@ -90,7 +89,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { //Skip final fields. if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) continue; - generateSetterForField(field, pos.get(), level, EMPTY_ANNOTATIONS_ARRAY, EMPTY_ANNOTATIONS_ARRAY); + generateSetterForField(field, pos.get(), level); } return true; } @@ -107,7 +106,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { * If not, the setter is still generated if it isn't already there, though there will not * be a warning if its already there. The default access level is used. */ - public void generateSetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, Annotation[] onMethod , Annotation[] onParam) { + public void generateSetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level) { for (EclipseNode child : fieldNode.down()) { if (child.getKind() == Kind.ANNOTATION) { if (annotationTypeMatches(Setter.class, child)) { @@ -117,7 +116,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { } } - createSetterForField(level, fieldNode, fieldNode, pos, false, onMethod, onParam); + createSetterForField(level, fieldNode, fieldNode, pos, false); } public void handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) { @@ -125,29 +124,24 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { AccessLevel level = annotation.getInstance().value(); if (level == AccessLevel.NONE || node == null) return; - Annotation[] onMethod = getAndRemoveAnnotationParameter(ast, "onMethod"); - Annotation[] onParam = getAndRemoveAnnotationParameter(ast, "onParam"); - switch (node.getKind()) { case FIELD: - createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, onParam); + createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true); break; case TYPE: - if (onMethod != null && onMethod.length != 0) annotationNode.addError("'onMethod' is not supported for @Setter on a type."); - if (onParam != null && onParam.length != 0) annotationNode.addError("'onParam' is not supported for @Setter on a type."); generateSetterForType(node, annotationNode, level, false); break; } } - private void createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod , Annotation[] onParam) { + private void createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists) { for (EclipseNode fieldNode : fieldNodes) { - createSetterForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, onParam); + createSetterForField(level, fieldNode, errorNode, source, whineIfExists); } } private void createSetterForField(AccessLevel level, - EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod , Annotation[] onParam) { + EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists) { if (fieldNode.getKind() != Kind.FIELD) { errorNode.addError("@Setter is only supported on a class or a field."); return; @@ -178,16 +172,11 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { } } - MethodDeclaration method = generateSetter((TypeDeclaration) fieldNode.up().get(), fieldNode, setterName, modifier, source, onParam); - Annotation[] copiedAnnotations = copyAnnotations(source, onMethod); - if (copiedAnnotations.length != 0) { - method.annotations = copiedAnnotations; - } - + MethodDeclaration method = generateSetter((TypeDeclaration) fieldNode.up().get(), fieldNode, setterName, modifier, source); injectMethod(fieldNode.up(), method); } - private MethodDeclaration generateSetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, Annotation[] onParam) { + private MethodDeclaration generateSetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; @@ -225,7 +214,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { if (nullCheck != null) method.statements = new Statement[] { nullCheck, assignment }; else method.statements = new Statement[] { assignment }; } - Annotation[] copiedAnnotations = copyAnnotations(source, nonNulls, nullables, onParam); + Annotation[] copiedAnnotations = copyAnnotations(source, nonNulls, nullables); if (copiedAnnotations.length != 0) param.annotations = copiedAnnotations; return method; } diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index 1aab828d..212daf16 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -69,8 +69,7 @@ public class HandleConstructor { String staticName = ann.staticName(); if (level == AccessLevel.NONE) return; List<JavacNode> fields = List.nil(); - List<JCExpression> onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, onConstructor, false, false, annotationNode); + new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, false, false, annotationNode); } } @@ -87,8 +86,7 @@ public class HandleConstructor { @SuppressWarnings("deprecation") boolean suppressConstructorProperties = ann.suppressConstructorProperties(); if (level == AccessLevel.NONE) return; - List<JCExpression> onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, onConstructor, false, suppressConstructorProperties, annotationNode); + new HandleConstructor().generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, false, suppressConstructorProperties, annotationNode); } } @@ -135,8 +133,7 @@ public class HandleConstructor { if (((fieldFlags & Flags.FINAL) != 0) && fieldDecl.init != null) continue; fields.append(child); } - List<JCExpression> onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor"); - new HandleConstructor().generateConstructor(typeNode, level, fields.toList(), staticName, onConstructor, false, suppressConstructorProperties, annotationNode); + new HandleConstructor().generateConstructor(typeNode, level, fields.toList(), staticName, false, suppressConstructorProperties, annotationNode); } } @@ -155,10 +152,10 @@ public class HandleConstructor { } public void generateRequiredArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, boolean skipIfConstructorExists, JavacNode source) { - generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, List.<JCExpression>nil(), skipIfConstructorExists, false, source); + generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, skipIfConstructorExists, false, source); } - public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JavacNode> fields, String staticName, List<JCExpression> onConstructor, boolean skipIfConstructorExists, boolean suppressConstructorProperties, JavacNode source) { + public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JavacNode> fields, String staticName, boolean skipIfConstructorExists, boolean suppressConstructorProperties, JavacNode source) { if (skipIfConstructorExists && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return; if (skipIfConstructorExists) { for (JavacNode child : typeNode.down()) { @@ -173,7 +170,7 @@ public class HandleConstructor { boolean staticConstrRequired = staticName != null && !staticName.equals(""); - JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fields, onConstructor, suppressConstructorProperties, source.get()); + JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fields, suppressConstructorProperties, source.get()); injectMethod(typeNode, constr); if (staticConstrRequired) { JCMethodDecl staticConstr = createStaticConstructor(staticName, level, typeNode, fields, source.get()); @@ -194,7 +191,7 @@ public class HandleConstructor { mods.annotations = mods.annotations.append(annotation); } - private JCMethodDecl createConstructor(AccessLevel level, JavacNode typeNode, List<JavacNode> fields, List<JCExpression> onConstructor, boolean suppressConstructorProperties, JCTree source) { + private JCMethodDecl createConstructor(AccessLevel level, JavacNode typeNode, List<JavacNode> fields, boolean suppressConstructorProperties, JCTree source) { TreeMaker maker = typeNode.getTreeMaker(); boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0; @@ -220,8 +217,7 @@ public class HandleConstructor { } } - List<JCAnnotation> annsOnConstructor = copyAnnotations(onConstructor); - JCModifiers mods = maker.Modifiers(toJavacModifier(level), annsOnConstructor); + JCModifiers mods = maker.Modifiers(toJavacModifier(level), List.<JCAnnotation>nil()); if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && !isLocalType(typeNode)) { addConstructorProperties(mods, typeNode, fields); } diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index e61ad7d7..0be00d89 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -93,7 +93,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { } for (JavacNode field : typeNode.down()) { - if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, errorNode.get(), level, List.<JCExpression>nil(), false); + if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, errorNode.get(), level, false); } } @@ -122,7 +122,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { * @param fieldNode The node representing the field you want a getter for. * @param pos The node responsible for generating the getter (the {@code @Data} or {@code @Getter} annotation). */ - public void generateGetterForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, List<JCExpression> onMethod, boolean lazy) { + public void generateGetterForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, boolean lazy) { for (JavacNode child : fieldNode.down()) { if (child.getKind() == Kind.ANNOTATION) { if (Javac.annotationTypeMatches(Getter.class, child)) { @@ -132,7 +132,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { } } - createGetterForField(level, fieldNode, fieldNode, false, onMethod, lazy); + createGetterForField(level, fieldNode, fieldNode, false, lazy); } @Override public void handle(AnnotationValues<Getter> annotation, JCAnnotation ast, JavacNode annotationNode) { @@ -152,27 +152,25 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { if (node == null) return; - List<JCExpression> onMethod = getAndRemoveAnnotationParameter(ast, "onMethod"); switch (node.getKind()) { case FIELD: - createGetterForFields(level, fields, annotationNode, true, onMethod, lazy); + createGetterForFields(level, fields, annotationNode, true, lazy); break; case TYPE: - if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Getter on a type."); if (lazy) annotationNode.addError("'lazy' is not supported for @Getter on a type."); generateGetterForType(node, annotationNode, level, false); break; } } - private void createGetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, List<JCExpression> onMethod, boolean lazy) { + private void createGetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, boolean lazy) { for (JavacNode fieldNode : fieldNodes) { - createGetterForField(level, fieldNode, errorNode, whineIfExists, onMethod, lazy); + createGetterForField(level, fieldNode, errorNode, whineIfExists, lazy); } } private void createGetterForField(AccessLevel level, - JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCExpression> onMethod, boolean lazy) { + JavacNode fieldNode, JavacNode source, boolean whineIfExists, boolean lazy) { if (fieldNode.getKind() != Kind.FIELD) { source.addError("@Getter is only supported on a class or a field."); return; @@ -213,10 +211,10 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC); - injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), onMethod, lazy, source.get())); + injectMethod(fieldNode.up(), createGetter(access, fieldNode, fieldNode.getTreeMaker(), lazy, source.get())); } - private JCMethodDecl createGetter(long access, JavacNode field, TreeMaker treeMaker, List<JCExpression> onMethod, boolean lazy, JCTree source) { + private JCMethodDecl createGetter(long access, JavacNode field, TreeMaker treeMaker, boolean lazy, JCTree source) { JCVariableDecl fieldNode = (JCVariableDecl) field.get(); // Remember the type; lazy will change it; @@ -242,7 +240,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { List<JCAnnotation> nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN); List<JCAnnotation> nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN); - List<JCAnnotation> annsOnMethod = copyAnnotations(onMethod).appendList(nonNulls).appendList(nullables); + List<JCAnnotation> annsOnMethod = nonNulls.appendList(nullables); JCMethodDecl decl = Javac.recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType, methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source); diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index 7763a017..8e29d974 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -96,7 +96,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { //Skip final fields. if ((fieldDecl.mods.flags & Flags.FINAL) != 0) continue; - generateSetterForField(field, errorNode.get(), level, List.<JCExpression>nil(), List.<JCExpression>nil()); + generateSetterForField(field, errorNode.get(), level); } } @@ -115,7 +115,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { * @param fieldNode The node representing the field you want a setter for. * @param pos The node responsible for generating the setter (the {@code @Data} or {@code @Setter} annotation). */ - public void generateSetterForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, List<JCExpression> onMethod, List<JCExpression> onParam) { + public void generateSetterForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) { for (JavacNode child : fieldNode.down()) { if (child.getKind() == Kind.ANNOTATION) { if (Javac.annotationTypeMatches(Setter.class, child)) { @@ -125,7 +125,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { } } - createSetterForField(level, fieldNode, fieldNode, false, onMethod, onParam); + createSetterForField(level, fieldNode, fieldNode, false); } @Override public void handle(AnnotationValues<Setter> annotation, JCAnnotation ast, JavacNode annotationNode) { @@ -137,32 +137,25 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { if (level == AccessLevel.NONE || node == null) return; - List<JCExpression> onParamList = getAndRemoveAnnotationParameter(ast, "onParam"); - List<JCExpression> onMethodList = getAndRemoveAnnotationParameter(ast, "onMethod"); - switch (node.getKind()) { case FIELD: - createSetterForFields(level, fields, annotationNode, true, onMethodList, onParamList); + createSetterForFields(level, fields, annotationNode, true); break; case TYPE: - if (!onMethodList.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Setter on a type."); - if (!onParamList.isEmpty()) annotationNode.addError("'onParam' is not supported for @Setter on a type."); - generateSetterForType(node, annotationNode, level, false); break; } } - private void createSetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists, - List<JCExpression> onMethod, List<JCExpression> onParam) { + private void createSetterForFields(AccessLevel level, Collection<JavacNode> fieldNodes, JavacNode errorNode, boolean whineIfExists) { for (JavacNode fieldNode : fieldNodes) { - createSetterForField(level, fieldNode, errorNode, whineIfExists, onMethod, onParam); + createSetterForField(level, fieldNode, errorNode, whineIfExists); } } private void createSetterForField(AccessLevel level, - JavacNode fieldNode, JavacNode source, boolean whineIfExists, List<JCExpression> onMethod, List<JCExpression> onParam) { + JavacNode fieldNode, JavacNode source, boolean whineIfExists) { if (fieldNode.getKind() != Kind.FIELD) { fieldNode.addError("@Setter is only supported on a class or a field."); @@ -192,10 +185,10 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { long access = toJavacModifier(level) | (fieldDecl.mods.flags & Flags.STATIC); - injectMethod(fieldNode.up(), createSetter(access, fieldNode, fieldNode.getTreeMaker(), onMethod, onParam, source.get())); + injectMethod(fieldNode.up(), createSetter(access, fieldNode, fieldNode.getTreeMaker(), source.get())); } - private JCMethodDecl createSetter(long access, JavacNode field, TreeMaker treeMaker, List<JCExpression> onMethod, List<JCExpression> onParam, JCTree source) { + private JCMethodDecl createSetter(long access, JavacNode field, TreeMaker treeMaker, JCTree source) { JCVariableDecl fieldDecl = (JCVariableDecl) field.get(); JCExpression fieldRef = createFieldAccessor(treeMaker, field, FieldAccess.ALWAYS_FIELD); @@ -215,8 +208,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { JCBlock methodBody = treeMaker.Block(0, statements); Name methodName = field.toName(toSetterName(fieldDecl)); - List<JCAnnotation> annsOnParam = copyAnnotations(onParam); - annsOnParam = annsOnParam.appendList(nonNulls).appendList(nullables); + List<JCAnnotation> annsOnParam = nonNulls.appendList(nullables); JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(Flags.FINAL, annsOnParam), fieldDecl.name, fieldDecl.vartype, null); //WARNING: Do not use field.getSymbolTable().voidType - that field has gone through non-backwards compatible API changes within javac1.6. JCExpression methodType = treeMaker.Type(new JCNoType(Javac.getCTCint(TypeTags.class, "VOID"))); @@ -226,7 +218,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { List<JCExpression> throwsClauses = List.nil(); JCExpression annotationMethodDefaultValue = null; - return Javac.recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, copyAnnotations(onMethod)), methodName, methodType, + return Javac.recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, List.<JCAnnotation>nil()), methodName, methodType, methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source); } |