aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/javac/handlers/HandleSetter.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-10-16 09:32:36 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-10-16 09:32:36 +0200
commitb5c8b725655d2ad8a715cfb1fbbdf25dbdcd4ceb (patch)
tree571d13cd7028a6b7d1ebfe84180a4328a20c42d7 /src/lombok/javac/handlers/HandleSetter.java
parent8629a651a66aa5fba9e0ada7df00803528b0e34f (diff)
downloadlombok-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/javac/handlers/HandleSetter.java')
-rw-r--r--src/lombok/javac/handlers/HandleSetter.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lombok/javac/handlers/HandleSetter.java b/src/lombok/javac/handlers/HandleSetter.java
index 44ad0dca..f7360988 100644
--- a/src/lombok/javac/handlers/HandleSetter.java
+++ b/src/lombok/javac/handlers/HandleSetter.java
@@ -28,9 +28,8 @@ import lombok.core.AnnotationValues;
import lombok.core.TransformationsUtil;
import lombok.core.AST.Kind;
import lombok.javac.Javac;
-import lombok.javac.JavacAST;
import lombok.javac.JavacAnnotationHandler;
-import lombok.javac.JavacAST.Node;
+import lombok.javac.JavacNode;
import org.mangosdk.spi.ProviderFor;
@@ -66,10 +65,10 @@ public class HandleSetter implements JavacAnnotationHandler<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, DiagnosticPosition pos) {
- for ( Node child : fieldNode.down() ) {
- if ( child.getKind() == Kind.ANNOTATION ) {
- if ( Javac.annotationTypeMatches(Setter.class, child) ) {
+ public void generateSetterForField(JavacNode fieldNode, DiagnosticPosition pos) {
+ for (JavacNode child : fieldNode.down()) {
+ if (child.getKind() == Kind.ANNOTATION) {
+ if (Javac.annotationTypeMatches(Setter.class, child)) {
//The annotation will make it happen, so we can skip it.
return;
}
@@ -79,16 +78,17 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
createSetterForField(AccessLevel.PUBLIC, fieldNode, fieldNode, pos, false);
}
- @Override public boolean handle(AnnotationValues<Setter> annotation, JCAnnotation ast, Node annotationNode) {
- Node fieldNode = annotationNode.up();
+ @Override public boolean handle(AnnotationValues<Setter> annotation, JCAnnotation ast, JavacNode annotationNode) {
+ JavacNode fieldNode = annotationNode.up();
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, DiagnosticPosition pos, boolean whineIfExists) {
- if ( fieldNode.getKind() != Kind.FIELD ) {
+ private boolean createSetterForField(AccessLevel level,
+ JavacNode fieldNode, JavacNode errorNode, DiagnosticPosition pos, boolean whineIfExists) {
+ if (fieldNode.getKind() != Kind.FIELD) {
fieldNode.addError("@Setter is only supported on a field.");
return true;
}
@@ -96,11 +96,11 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
JCVariableDecl fieldDecl = (JCVariableDecl)fieldNode.get();
String methodName = toSetterName(fieldDecl);
- switch ( methodExists(methodName, fieldNode) ) {
+ switch (methodExists(methodName, 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",
methodName, fieldDecl.vartype, fieldDecl.name));
return true;
@@ -116,7 +116,7 @@ public class HandleSetter implements JavacAnnotationHandler<Setter> {
return true;
}
- private JCMethodDecl createSetter(long access, JavacAST.Node field, TreeMaker treeMaker) {
+ private JCMethodDecl createSetter(long access, JavacNode field, TreeMaker treeMaker) {
JCVariableDecl fieldDecl = (JCVariableDecl) field.get();
JCFieldAccess thisX = treeMaker.Select(treeMaker.Ident(field.toName("this")), fieldDecl.name);