diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleData.java | 4 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleGetter.java | 13 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleSetter.java | 40 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleValue.java | 2 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleData.java | 5 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleGetter.java | 13 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleSetter.java | 12 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/HandleValue.java | 3 |
8 files changed, 39 insertions, 53 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleData.java b/src/core/lombok/eclipse/handlers/HandleData.java index 025ceefd..5d92cd36 100644 --- a/src/core/lombok/eclipse/handlers/HandleData.java +++ b/src/core/lombok/eclipse/handlers/HandleData.java @@ -72,8 +72,8 @@ public class HandleData extends EclipseAnnotationHandler<Data> { //for whatever reason, though you can find callers of that one by focusing on the class name itself //and hitting 'find callers'. - handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); - handleSetter.generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); + handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, Collections.<Annotation>emptyList()); + handleSetter.generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, Collections.<Annotation>emptyList(), Collections.<Annotation>emptyList()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); handleToString.generateToStringForType(typeNode, annotationNode); handleConstructor.generateRequiredArgsConstructor( diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index f417aca5..533b97c4 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -80,7 +80,7 @@ import org.mangosdk.spi.ProviderFor; public class HandleGetter extends EclipseAnnotationHandler<Getter> { private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0]; - public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter) { + public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter, List<Annotation> onMethod) { if (checkForTypeLevelGetter) { if (hasAnnotation(Getter.class, typeNode)) { //The annotation will make it happen, so we can skip it. @@ -100,7 +100,7 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { } for (EclipseNode field : typeNode.down()) { - if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, pos.get(), level, false); + if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, pos.get(), level, false, onMethod); } return true; } @@ -123,13 +123,13 @@ 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, boolean lazy) { + public void generateGetterForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level, boolean lazy, List<Annotation> onMethod) { if (hasAnnotation(Getter.class, fieldNode)) { //The annotation will make it happen, so we can skip it. return; } - createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, Collections.<Annotation>emptyList()); + createGetterForField(level, fieldNode, fieldNode, pos, false, lazy, onMethod); } public void handle(AnnotationValues<Getter> annotation, Annotation ast, EclipseNode annotationNode) { @@ -155,11 +155,8 @@ public class HandleGetter extends EclipseAnnotationHandler<Getter> { createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, lazy, onMethod); 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); + generateGetterForType(node, annotationNode, level, false, onMethod); break; } } diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java index 6a9a5123..ab40b1e5 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.java @@ -24,22 +24,14 @@ package lombok.eclipse.handlers; import static lombok.core.handlers.HandlerUtil.*; import static lombok.eclipse.Eclipse.*; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; +import static lombok.eclipse.handlers.EclipseHandlerUtil.toAllSetterNames; +import static lombok.eclipse.handlers.EclipseHandlerUtil.toSetterName; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; -import lombok.AccessLevel; -import lombok.ConfigurationKeys; -import lombok.Setter; -import lombok.core.AST.Kind; -import lombok.core.AnnotationValues; -import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseNode; -import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess; - import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.Annotation; import org.eclipse.jdt.internal.compiler.ast.Argument; @@ -59,12 +51,21 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.mangosdk.spi.ProviderFor; +import lombok.AccessLevel; +import lombok.ConfigurationKeys; +import lombok.Setter; +import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; +import lombok.eclipse.handlers.EclipseHandlerUtil.FieldAccess; + /** * Handles the {@code lombok.Setter} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) public class HandleSetter extends EclipseAnnotationHandler<Setter> { - public boolean generateSetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelSetter) { + public boolean generateSetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelSetter, List<Annotation> onMethod, List<Annotation> onParam) { if (checkForTypeLevelSetter) { if (hasAnnotation(Setter.class, typeNode)) { //The annotation will make it happen, so we can skip it. @@ -91,7 +92,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { //Skip final fields. if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) continue; - generateSetterForField(field, pos, level); + generateSetterForField(field, pos, level, onMethod, onParam); } return true; } @@ -108,15 +109,12 @@ 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, EclipseNode sourceNode, AccessLevel level) { + public void generateSetterForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level, List<Annotation> onMethod, List<Annotation> onParam) { if (hasAnnotation(Setter.class, fieldNode)) { //The annotation will make it happen, so we can skip it. return; } - - List<Annotation> empty = Collections.emptyList(); - - createSetterForField(level, fieldNode, sourceNode, false, empty, empty); + createSetterForField(level, fieldNode, sourceNode, false, onMethod, onParam); } public void handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) { @@ -134,13 +132,7 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> { createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam); break; case TYPE: - if (!onMethod.isEmpty()) { - annotationNode.addError("'onMethod' is not supported for @Setter on a type."); - } - if (!onParam.isEmpty()) { - annotationNode.addError("'onParam' is not supported for @Setter on a type."); - } - generateSetterForType(node, annotationNode, level, false); + generateSetterForType(node, annotationNode, level, false, onMethod, onParam); break; } } diff --git a/src/core/lombok/eclipse/handlers/HandleValue.java b/src/core/lombok/eclipse/handlers/HandleValue.java index a61ca6c3..bd93a547 100644 --- a/src/core/lombok/eclipse/handlers/HandleValue.java +++ b/src/core/lombok/eclipse/handlers/HandleValue.java @@ -86,7 +86,7 @@ public class HandleValue extends EclipseAnnotationHandler<Value> { //for whatever reason, though you can find callers of that one by focusing on the class name itself //and hitting 'find callers'. - handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); + handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, Collections.<Annotation>emptyList()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); handleToString.generateToStringForType(typeNode, annotationNode); handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, ann.staticConstructor(), SkipIfConstructorExists.YES, diff --git a/src/core/lombok/javac/handlers/HandleData.java b/src/core/lombok/javac/handlers/HandleData.java index 15f1fd83..94b6c3e1 100644 --- a/src/core/lombok/javac/handlers/HandleData.java +++ b/src/core/lombok/javac/handlers/HandleData.java @@ -34,6 +34,7 @@ import lombok.javac.handlers.HandleConstructor.SkipIfConstructorExists; import org.mangosdk.spi.ProviderFor; import com.sun.tools.javac.tree.JCTree.JCAnnotation; +import com.sun.tools.javac.util.List; /** * Handles the {@code lombok.Data} annotation for javac. @@ -61,8 +62,8 @@ public class HandleData extends JavacAnnotationHandler<Data> { String staticConstructorName = annotation.getInstance().staticConstructor(); handleConstructor.generateRequiredArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, SkipIfConstructorExists.YES, annotationNode); - handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); - handleSetter.generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); + handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil()); + handleSetter.generateSetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil(), List.<JCAnnotation>nil()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); handleToString.generateToStringForType(typeNode, annotationNode); } diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java index 0540465d..7e6598a7 100644 --- a/src/core/lombok/javac/handlers/HandleGetter.java +++ b/src/core/lombok/javac/handlers/HandleGetter.java @@ -72,7 +72,7 @@ import com.sun.tools.javac.util.Name; */ @ProviderFor(JavacAnnotationHandler.class) public class HandleGetter extends JavacAnnotationHandler<Getter> { - public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter) { + public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter, List<JCAnnotation> onMethod) { if (checkForTypeLevelGetter) { if (hasAnnotation(Getter.class, typeNode)) { //The annotation will make it happen, so we can skip it. @@ -91,7 +91,7 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { } for (JavacNode field : typeNode.down()) { - if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, errorNode.get(), level, false); + if (fieldQualifiesForGetterGeneration(field)) generateGetterForField(field, errorNode.get(), level, false, onMethod); } } @@ -120,12 +120,12 @@ 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, boolean lazy) { + public void generateGetterForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level, boolean lazy, List<JCAnnotation> onMethod) { if (hasAnnotation(Getter.class, fieldNode)) { //The annotation will make it happen, so we can skip it. return; } - createGetterForField(level, fieldNode, fieldNode, false, lazy, List.<JCAnnotation>nil()); + createGetterForField(level, fieldNode, fieldNode, false, lazy, onMethod); } @Override public void handle(AnnotationValues<Getter> annotation, JCAnnotation ast, JavacNode annotationNode) { @@ -154,11 +154,8 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> { createGetterForFields(level, fields, annotationNode, true, lazy, onMethod); 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); + generateGetterForType(node, annotationNode, level, false, onMethod); break; } } diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java index 1453aa27..331b2fac 100644 --- a/src/core/lombok/javac/handlers/HandleSetter.java +++ b/src/core/lombok/javac/handlers/HandleSetter.java @@ -62,7 +62,7 @@ import com.sun.tools.javac.util.Name; */ @ProviderFor(JavacAnnotationHandler.class) public class HandleSetter extends JavacAnnotationHandler<Setter> { - public void generateSetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelSetter) { + public void generateSetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelSetter, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { if (checkForTypeLevelSetter) { if (hasAnnotation(Setter.class, typeNode)) { //The annotation will make it happen, so we can skip it. @@ -90,7 +90,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { //Skip final fields. if ((fieldDecl.mods.flags & Flags.FINAL) != 0) continue; - generateSetterForField(field, errorNode, level); + generateSetterForField(field, errorNode, level, onMethod, onParam); } } @@ -109,13 +109,13 @@ 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, JavacNode sourceNode, AccessLevel level) { + public void generateSetterForField(JavacNode fieldNode, JavacNode sourceNode, AccessLevel level, List<JCAnnotation> onMethod, List<JCAnnotation> onParam) { if (hasAnnotation(Setter.class, fieldNode)) { //The annotation will make it happen, so we can skip it. return; } - createSetterForField(level, fieldNode, sourceNode, false, List.<JCAnnotation>nil(), List.<JCAnnotation>nil()); + createSetterForField(level, fieldNode, sourceNode, false, onMethod, onParam); } @Override public void handle(AnnotationValues<Setter> annotation, JCAnnotation ast, JavacNode annotationNode) { @@ -137,9 +137,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> { createSetterForFields(level, fields, annotationNode, true, onMethod, onParam); break; case TYPE: - if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Setter on a type."); - if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Setter on a type."); - generateSetterForType(node, annotationNode, level, false); + generateSetterForType(node, annotationNode, level, false, onMethod, onParam); break; } } diff --git a/src/core/lombok/javac/handlers/HandleValue.java b/src/core/lombok/javac/handlers/HandleValue.java index d1af4168..f85e058e 100644 --- a/src/core/lombok/javac/handlers/HandleValue.java +++ b/src/core/lombok/javac/handlers/HandleValue.java @@ -40,6 +40,7 @@ import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCModifiers; +import com.sun.tools.javac.util.List; /** * Handles the {@code lombok.Value} annotation for javac. @@ -76,7 +77,7 @@ public class HandleValue extends JavacAnnotationHandler<Value> { } handleFieldDefaults.generateFieldDefaultsForType(typeNode, annotationNode, AccessLevel.PRIVATE, true, true); handleConstructor.generateAllArgsConstructor(typeNode, AccessLevel.PUBLIC, staticConstructorName, SkipIfConstructorExists.YES, annotationNode); - handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true); + handleGetter.generateGetterForType(typeNode, annotationNode, AccessLevel.PUBLIC, true, List.<JCAnnotation>nil()); handleEqualsAndHashCode.generateEqualsAndHashCodeForType(typeNode, annotationNode); handleToString.generateToStringForType(typeNode, annotationNode); } |