aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2011-08-15 21:21:51 +0200
committerRoel Spilker <r.spilker@gmail.com>2011-08-15 21:21:51 +0200
commita284600987065aa78bc41b2099421f864cfcec20 (patch)
tree1c8b7dd807bef387bba0c0cda42b8d6550bd3ce3 /src/core/lombok/javac/handlers
parent55cb9f8dac271fe0facd2ce2ad365f8084942181 (diff)
downloadlombok-a284600987065aa78bc41b2099421f864cfcec20.tar.gz
lombok-a284600987065aa78bc41b2099421f864cfcec20.tar.bz2
lombok-a284600987065aa78bc41b2099421f864cfcec20.zip
Removed support for onMethod, onParam and onConstructor due to javac7 type incapabilities. Issue #251
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java20
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java22
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java30
3 files changed, 29 insertions, 43 deletions
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);
}