aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-07-20 11:58:56 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-07-20 11:58:56 +0200
commitd7ee0bc8a5a36e5968741e0e0a445a165b32f1e5 (patch)
treee5479876073490c3ea86ee5f24e2017ee749341a /src/core/lombok/eclipse
parentba7406f05a7b88e06bb1d4c52e9000c85e65387c (diff)
downloadlombok-d7ee0bc8a5a36e5968741e0e0a445a165b32f1e5.tar.gz
lombok-d7ee0bc8a5a36e5968741e0e0a445a165b32f1e5.tar.bz2
lombok-d7ee0bc8a5a36e5968741e0e0a445a165b32f1e5.zip
@Getter int x, y; used to only apply to 'x', now it applies to both x and y.
Fixes issue #54
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/EclipseNode.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java12
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java10
3 files changed, 30 insertions, 2 deletions
diff --git a/src/core/lombok/eclipse/EclipseNode.java b/src/core/lombok/eclipse/EclipseNode.java
index 668e6a6e..335845b5 100644
--- a/src/core/lombok/eclipse/EclipseNode.java
+++ b/src/core/lombok/eclipse/EclipseNode.java
@@ -122,6 +122,16 @@ public class EclipseNode extends lombok.core.LombokNode<EclipseAST, EclipseNode,
}
}
+ @Override protected boolean fieldContainsAnnotation(ASTNode field, ASTNode annotation) {
+ if (!(field instanceof FieldDeclaration)) return false;
+ FieldDeclaration f = (FieldDeclaration) field;
+ if (f.annotations == null) return false;
+ for (Annotation childAnnotation : f.annotations) {
+ if (childAnnotation == annotation) return true;
+ }
+ return false;
+ }
+
/** {@inheritDoc} */
@Override public String getName() {
final char[] n;
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index 9a676eb5..70423fbf 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -23,6 +23,9 @@ package lombok.eclipse.handlers;
import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
+
+import java.util.Collection;
+
import lombok.AccessLevel;
import lombok.Getter;
import lombok.core.AnnotationValues;
@@ -94,7 +97,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
if (node == null) return false;
if (node.getKind() == Kind.FIELD) {
- return createGetterForField(level, node, annotationNode, annotationNode.get(), true);
+ return createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true);
}
if (node.getKind() == Kind.TYPE) {
TypeDeclaration typeDecl = null;
@@ -117,6 +120,13 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
return false;
}
+ private boolean createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
+ for (EclipseNode fieldNode : fieldNodes) {
+ createGetterForField(level, fieldNode, errorNode, source, whineIfExists);
+ }
+ return true;
+ }
+
private boolean createGetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
if (fieldNode.getKind() != Kind.FIELD) {
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index 3dbbb2b5..ccdbbb2c 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -25,6 +25,7 @@ import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import java.lang.reflect.Modifier;
+import java.util.Collection;
import lombok.AccessLevel;
import lombok.Setter;
@@ -101,7 +102,7 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
if (node == null) return false;
if (node.getKind() == Kind.FIELD) {
- return createSetterForField(level, node, annotationNode, annotationNode.get(), true);
+ return createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true);
}
if (node.getKind() == Kind.TYPE) {
TypeDeclaration typeDecl = null;
@@ -124,6 +125,13 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
return false;
}
+ private boolean createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists) {
+ for (EclipseNode fieldNode : fieldNodes) {
+ createSetterForField(level, fieldNode, errorNode, source, whineIfExists);
+ }
+ return true;
+ }
+
private boolean createSetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode pos, boolean whineIfExists) {
if (fieldNode.getKind() != Kind.FIELD) {