aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-03-22 17:17:06 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-03-22 17:17:06 +0100
commit4689d2a9bf79f592690a71e7ad7d25cb38b2344b (patch)
tree8f84d622bc93a351b13c0433a644c2e704ffbc31 /src/core/lombok/eclipse
parent389dbf5edadfb61e808e7d5273bb11990821ff9f (diff)
parenteb317c58df89c263b9ce12a49b0ab660e78b2f53 (diff)
downloadlombok-4689d2a9bf79f592690a71e7ad7d25cb38b2344b.tar.gz
lombok-4689d2a9bf79f592690a71e7ad7d25cb38b2344b.tar.bz2
lombok-4689d2a9bf79f592690a71e7ad7d25cb38b2344b.zip
Merge remote branch 'origin/master'
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java21
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java10
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java4
3 files changed, 32 insertions, 3 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index f795197b..67a2d07c 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -245,6 +245,27 @@ public class EclipseHandlerUtil {
return node;
}
+ public static MarkerAnnotation generateDeprecatedAnnotation(ASTNode source) {
+ QualifiedTypeReference qtr = new QualifiedTypeReference(new char[][] {
+ {'j', 'a', 'v', 'a'}, {'l', 'a', 'n', 'g'}, {'D', 'e', 'p', 'r', 'e', 'c', 'a', 't', 'e', 'd'}}, poss(source, 3));
+ setGeneratedBy(qtr, source);
+ return new MarkerAnnotation(qtr, source.sourceStart);
+ }
+
+ public static boolean isFieldDeprecated(EclipseNode fieldNode) {
+ FieldDeclaration field = (FieldDeclaration) fieldNode.get();
+ if ((field.modifiers & ClassFileConstants.AccDeprecated) != 0) {
+ return true;
+ }
+ if (field.annotations == null) return false;
+ for (Annotation annotation : field.annotations) {
+ if (typeMatches(Deprecated.class, fieldNode, annotation.type)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Checks if the given TypeReference node is likely to be a reference to the provided class.
*
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index 92f1177f..3bdba74e 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -212,14 +212,20 @@ 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), findDelegatesAndMarkAsHandled(fieldNode));
+
+ Annotation[] deprecated = null;
+ if (isFieldDeprecated(fieldNode)) {
+ deprecated = new Annotation[] { generateDeprecatedAnnotation(source) };
+ }
+
+ Annotation[] copiedAnnotations = copyAnnotations(source, findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN), findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN), findDelegatesAndMarkAsHandled(fieldNode), deprecated);
if (copiedAnnotations.length != 0) {
method.annotations = copiedAnnotations;
}
injectMethod(fieldNode.up(), method);
}
-
+
private static Annotation[] findDelegatesAndMarkAsHandled(EclipseNode fieldNode) {
List<Annotation> delegates = new ArrayList<Annotation>();
for (EclipseNode child : fieldNode.down()) {
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index ea81965b..8599fca7 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -184,7 +184,9 @@ public class HandleSetter extends EclipseAnnotationHandler<Setter> {
method.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
method.returnType.sourceStart = pS; method.returnType.sourceEnd = pE;
setGeneratedBy(method.returnType, source);
- method.annotations = null;
+ if (isFieldDeprecated(fieldNode)) {
+ method.annotations = new Annotation[] { generateDeprecatedAnnotation(source) };
+ }
Argument param = new Argument(field.name, p, copyType(field.type, source), Modifier.FINAL);
param.sourceStart = pS; param.sourceEnd = pE;
setGeneratedBy(param, source);