Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue 348: @Delegate should also generate @Deprecated when the interf…

…ace methods javadoc contains@deprecated
  • Loading branch information...
commit 4c8cc228e8f72972fa91a6c96d6e5bdf5ab6905c 2 parents 7988f17 + 73dab3e
@rspilker rspilker authored
View
1  AUTHORS
@@ -6,5 +6,6 @@ Reinier Zwitserloot <reinier@zwitserloot.com>
Robbert Jan Grootjans <grootjans@gmail.com>
Roel Spilker <r.spilker@gmail.com>
Sander Koning <askoning@gmail.com>
+Taiki Sugawara <buzz.taiki@gmail.com>
By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok.
View
3  src/core/lombok/javac/handlers/HandleDelegate.java
@@ -22,6 +22,7 @@
package lombok.javac.handlers;
import static lombok.javac.handlers.JavacHandlerUtil.*;
+import static com.sun.tools.javac.code.Flags.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -335,7 +336,7 @@ private void addMethodBindings(List<MethodSig> signatures, ClassType ct, JavacTy
ExecutableType methodType = (ExecutableType) types.asMemberOf(ct, member);
String sig = printSig(methodType, member.name, types);
if (!banList.add(sig)) continue; //If add returns false, it was already in there
- boolean isDeprecated = exElem.getAnnotation(Deprecated.class) != null;
+ boolean isDeprecated = (member.flags() & DEPRECATED) != 0;
signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem));
}
View
18 src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
@@ -21,8 +21,8 @@
*/
package lombok.eclipse.agent;
-import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import static lombok.eclipse.Eclipse.*;
+import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -65,7 +65,6 @@
import org.eclipse.jdt.internal.compiler.ast.TypeParameter;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding;
import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding;
import org.eclipse.jdt.internal.compiler.lookup.Binding;
@@ -416,19 +415,6 @@ private static void generateDelegateMethods(EclipseNode typeNode, List<BindingTu
}
}
- private static boolean hasDeprecatedAnnotation(MethodBinding binding) {
- AnnotationBinding[] annotations = binding.getAnnotations();
- if (annotations != null) for (AnnotationBinding ann : annotations) {
- ReferenceBinding annType = ann.getAnnotationType();
- char[] pkg = annType.qualifiedPackageName();
- char[] src = annType.qualifiedSourceName();
-
- if (charArrayEquals("java.lang", pkg) && charArrayEquals("Deprecated", src)) return true;
- }
-
- return false;
- }
-
public static void checkConflictOfTypeVarNames(BindingTuple binding, EclipseNode typeNode) throws CantMakeDelegates {
TypeVariableBinding[] typeVars = binding.parameterized.typeVariables();
if (typeVars == null || typeVars.length == 0) return;
@@ -581,7 +567,7 @@ private static MethodDeclaration createDelegateMethod(char[] name, EclipseNode t
method.modifiers = ClassFileConstants.AccPublic;
method.returnType = makeType(binding.returnType, source, false);
- boolean isDeprecated = hasDeprecatedAnnotation(binding);
+ boolean isDeprecated = binding.isDeprecated();
method.selector = binding.selector;
View
24 test/transform/resource/after-delombok/DelegateWithDeprecated.java
@@ -0,0 +1,24 @@
+class DelegateWithDeprecated {
+ private Bar bar;
+ private interface Bar {
+ @Deprecated
+ void deprecatedAnnotation();
+ /** @deprecated */
+ void deprecatedComment();
+ void notDeprecated();
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public void deprecatedAnnotation() {
+ this.bar.deprecatedAnnotation();
+ }
+ @java.lang.Deprecated
+ @java.lang.SuppressWarnings("all")
+ public void deprecatedComment() {
+ this.bar.deprecatedComment();
+ }
+ @java.lang.SuppressWarnings("all")
+ public void notDeprecated() {
+ this.bar.notDeprecated();
+ }
+}
View
21 test/transform/resource/after-ecj/DelegateWithDeprecated.java
@@ -0,0 +1,21 @@
+import lombok.Delegate;
+class DelegateWithDeprecated {
+ private interface Bar {
+ @Deprecated void deprecatedAnnotation();
+ void deprecatedComment();
+ void notDeprecated();
+ }
+ private @Delegate Bar bar;
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void deprecatedAnnotation() {
+ this.bar.deprecatedAnnotation();
+ }
+ public @java.lang.Deprecated @java.lang.SuppressWarnings("all") void deprecatedComment() {
+ this.bar.deprecatedComment();
+ }
+ public @java.lang.SuppressWarnings("all") void notDeprecated() {
+ this.bar.notDeprecated();
+ }
+ DelegateWithDeprecated() {
+ super();
+ }
+}
View
13 test/transform/resource/before/DelegateWithDeprecated.java
@@ -0,0 +1,13 @@
+import lombok.Delegate;
+
+class DelegateWithDeprecated {
+ @Delegate private Bar bar;
+
+ private interface Bar {
+ @Deprecated
+ void deprecatedAnnotation();
+ /** @deprecated */
+ void deprecatedComment();
+ void notDeprecated();
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.