diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-10-16 09:32:36 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-10-16 09:32:36 +0200 |
commit | b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb (patch) | |
tree | 571d13cd7028a6b7d1ebfe84180a4328a20c42d7 /src/lombok/eclipse/handlers/HandleSetter.java | |
parent | 8629a651a66aa5fba9e0ada7df00803528b0e34f (diff) | |
download | lombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.tar.gz lombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.tar.bz2 lombok-b5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb.zip |
Fixed issue #24 by refactoring the AST.Node class - taken it out, and in the process fixed a lot of type annoyance by adding more generics.
Also changed coding style from for/while/if/switch/catch/do ( expr ) {} to for (expr) {}, hence the changes _everywhere_.
Diffstat (limited to 'src/lombok/eclipse/handlers/HandleSetter.java')
-rw-r--r-- | src/lombok/eclipse/handlers/HandleSetter.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lombok/eclipse/handlers/HandleSetter.java b/src/lombok/eclipse/handlers/HandleSetter.java index f804eefc..0ef3c44b 100644 --- a/src/lombok/eclipse/handlers/HandleSetter.java +++ b/src/lombok/eclipse/handlers/HandleSetter.java @@ -33,7 +33,7 @@ import lombok.core.TransformationsUtil; import lombok.core.AST.Kind; import lombok.eclipse.Eclipse; import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseAST.Node; +import lombok.eclipse.EclipseNode; import org.eclipse.jdt.internal.compiler.ast.ASTNode; import org.eclipse.jdt.internal.compiler.ast.Annotation; @@ -69,10 +69,10 @@ public class HandleSetter implements 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(Node fieldNode, ASTNode pos) { - for ( Node child : fieldNode.down() ) { - if ( child.getKind() == Kind.ANNOTATION ) { - if ( annotationTypeMatches(Setter.class, child) ) { + public void generateSetterForField(EclipseNode fieldNode, ASTNode pos) { + for (EclipseNode child : fieldNode.down()) { + if (child.getKind() == Kind.ANNOTATION) { + if (annotationTypeMatches(Setter.class, child)) { //The annotation will make it happen, so we can skip it. return; } @@ -82,17 +82,18 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> { createSetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false); } - public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, Node annotationNode) { - Node fieldNode = annotationNode.up(); - if ( fieldNode.getKind() != Kind.FIELD ) return false; + public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) { + EclipseNode fieldNode = annotationNode.up(); + if (fieldNode.getKind() != Kind.FIELD) return false; AccessLevel level = annotation.getInstance().value(); - if ( level == AccessLevel.NONE ) return true; + if (level == AccessLevel.NONE) return true; return createSetterForField(level, fieldNode, annotationNode, annotationNode.get(), true); } - private boolean createSetterForField(AccessLevel level, Node fieldNode, Node errorNode, ASTNode pos, boolean whineIfExists) { - if ( fieldNode.getKind() != Kind.FIELD ) { + private boolean createSetterForField(AccessLevel level, + EclipseNode fieldNode, EclipseNode errorNode, ASTNode pos, boolean whineIfExists) { + if (fieldNode.getKind() != Kind.FIELD) { errorNode.addError("@Setter is only supported on a field."); return true; } @@ -102,11 +103,11 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> { int modifier = toModifier(level) | (field.modifiers & ClassFileConstants.AccStatic); - switch ( methodExists(setterName, fieldNode) ) { + switch (methodExists(setterName, fieldNode)) { case EXISTS_BY_LOMBOK: return true; case EXISTS_BY_USER: - if ( whineIfExists ) errorNode.addWarning( + if (whineIfExists) errorNode.addWarning( String.format("Not generating %s(%s %s): A method with that name already exists", setterName, field.type, new String(field.name))); return true; @@ -115,7 +116,6 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> { //continue with creating the setter } - MethodDeclaration method = generateSetter((TypeDeclaration) fieldNode.up().get(), field, setterName, modifier, pos); injectMethod(fieldNode.up(), method); |