aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
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/eclipse
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/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java18
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java18
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java31
3 files changed, 25 insertions, 42 deletions
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;
}