aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/javac/handlers')
-rw-r--r--src/core/lombok/javac/handlers/HandleGetter.java11
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java7
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java20
3 files changed, 31 insertions, 7 deletions
diff --git a/src/core/lombok/javac/handlers/HandleGetter.java b/src/core/lombok/javac/handlers/HandleGetter.java
index c286ed24..b3421f86 100644
--- a/src/core/lombok/javac/handlers/HandleGetter.java
+++ b/src/core/lombok/javac/handlers/HandleGetter.java
@@ -74,11 +74,9 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
public void generateGetterForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean checkForTypeLevelGetter) {
if (checkForTypeLevelGetter) {
if (typeNode != null) for (JavacNode child : typeNode.down()) {
- if (child.getKind() == Kind.ANNOTATION) {
- if (annotationTypeMatches(Getter.class, child)) {
- //The annotation will make it happen, so we can skip it.
- return;
- }
+ if (annotationTypeMatches(Getter.class, child)) {
+ //The annotation will make it happen, so we can skip it.
+ return;
}
}
}
@@ -244,6 +242,9 @@ public class HandleGetter extends JavacAnnotationHandler<Getter> {
List<JCAnnotation> delegates = findDelegatesAndRemoveFromField(field);
List<JCAnnotation> annsOnMethod = nonNulls.appendList(nullables);
+ if (isFieldDeprecated(field)) {
+ annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(chainDots(field, "java", "lang", "Deprecated"), List.<JCExpression>nil()));
+ }
JCMethodDecl decl = recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index db1fa724..0298311e 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -208,6 +208,7 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
JCBlock methodBody = treeMaker.Block(0, statements);
Name methodName = field.toName(toSetterName(fieldDecl));
List<JCAnnotation> annsOnParam = nonNulls.appendList(nullables);
+
JCVariableDecl param = treeMaker.VarDef(treeMaker.Modifiers(Flags.FINAL, annsOnParam), fieldDecl.name, fieldDecl.vartype, null);
//WARNING: Do not use field.getSymbolTable().voidType - that field has gone through non-backwards compatible API changes within javac1.6.
JCExpression methodType = treeMaker.Type(new JCNoType(getCtcInt(TypeTags.class, "VOID")));
@@ -217,7 +218,11 @@ public class HandleSetter extends JavacAnnotationHandler<Setter> {
List<JCExpression> throwsClauses = List.nil();
JCExpression annotationMethodDefaultValue = null;
- return recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, List.<JCAnnotation>nil()), methodName, methodType,
+ List<JCAnnotation> annsOnMethod = List.nil();
+ if (isFieldDeprecated(field)) {
+ annsOnMethod = annsOnMethod.prepend(treeMaker.Annotation(chainDots(field, "java", "lang", "Deprecated"), List.<JCExpression>nil()));
+ }
+ return recursiveSetGeneratedBy(treeMaker.MethodDef(treeMaker.Modifiers(access, annsOnMethod), methodName, methodType,
methodGenericParams, parameters, throwsClauses, methodBody, annotationMethodDefaultValue), source);
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 244f7d38..32b17322 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2011 The Project Lombok Authors.
+ * Copyright (C) 2009-2012 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -142,6 +142,24 @@ public class JavacHandlerUtil {
}
/**
+ * Returns if a field is marked deprecated, either by {@code @Deprecated} or in javadoc
+ * @param field the field to check
+ * @return {@code true} if a field is marked deprecated, either by {@code @Deprecated} or in javadoc, otherwise {@code false}
+ */
+ public static boolean isFieldDeprecated(JavacNode field) {
+ JCVariableDecl fieldNode = (JCVariableDecl) field.get();
+ if ((fieldNode.mods.flags & Flags.DEPRECATED) != 0) {
+ return true;
+ }
+ for (JavacNode child : field.down()) {
+ if (annotationTypeMatches(Deprecated.class, child)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Creates an instance of {@code AnnotationValues} for the provided AST Node.
*
* @param type An annotation class type, such as {@code lombok.Getter.class}.