From c809047b7892e4729f892445f730dff1d21065d6 Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Wed, 22 Feb 2012 05:01:35 +0900 Subject: support delegate with deprecated comment. --- src/core/lombok/javac/handlers/HandleDelegate.java | 3 ++- .../after-delombok/DelegateWithDeprecated.java | 29 ++++++++++++++++++++++ .../resource/after-ecj/DelegateWithDeprecated.java | 29 ++++++++++++++++++++++ .../resource/before/DelegateWithDeprecated.java | 13 ++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 test/transform/resource/after-delombok/DelegateWithDeprecated.java create mode 100644 test/transform/resource/after-ecj/DelegateWithDeprecated.java create mode 100644 test/transform/resource/before/DelegateWithDeprecated.java diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java index 9eca23db..25f29698 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/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; @@ -329,7 +330,7 @@ public class HandleDelegate extends JavacAnnotationHandler { 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 = exElem.getAnnotation(Deprecated.class) != null || (member.flags() & DEPRECATED) != 0; signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem)); } diff --git a/test/transform/resource/after-delombok/DelegateWithDeprecated.java b/test/transform/resource/after-delombok/DelegateWithDeprecated.java new file mode 100644 index 00000000..011eaf36 --- /dev/null +++ b/test/transform/resource/after-delombok/DelegateWithDeprecated.java @@ -0,0 +1,29 @@ +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(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/DelegateWithDeprecated.java b/test/transform/resource/after-ecj/DelegateWithDeprecated.java new file mode 100644 index 00000000..011eaf36 --- /dev/null +++ b/test/transform/resource/after-ecj/DelegateWithDeprecated.java @@ -0,0 +1,29 @@ +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(); + } +} \ No newline at end of file diff --git a/test/transform/resource/before/DelegateWithDeprecated.java b/test/transform/resource/before/DelegateWithDeprecated.java new file mode 100644 index 00000000..b748c6ec --- /dev/null +++ b/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(); + } +} \ No newline at end of file -- cgit From c63d036e78790a6bd4750d778effe2a63914dbaa Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Fri, 24 Feb 2012 22:56:42 +0900 Subject: Remove spaces in after files. --- test/transform/resource/after-delombok/DelegateWithDeprecated.java | 5 ----- test/transform/resource/after-ecj/DelegateWithDeprecated.java | 5 ----- 2 files changed, 10 deletions(-) diff --git a/test/transform/resource/after-delombok/DelegateWithDeprecated.java b/test/transform/resource/after-delombok/DelegateWithDeprecated.java index 011eaf36..04e12160 100644 --- a/test/transform/resource/after-delombok/DelegateWithDeprecated.java +++ b/test/transform/resource/after-delombok/DelegateWithDeprecated.java @@ -1,17 +1,12 @@ 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() { diff --git a/test/transform/resource/after-ecj/DelegateWithDeprecated.java b/test/transform/resource/after-ecj/DelegateWithDeprecated.java index 011eaf36..04e12160 100644 --- a/test/transform/resource/after-ecj/DelegateWithDeprecated.java +++ b/test/transform/resource/after-ecj/DelegateWithDeprecated.java @@ -1,17 +1,12 @@ 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() { -- cgit From 821370e01b1c1878c36da81c5baa93bf1dd5c973 Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Fri, 24 Feb 2012 23:55:02 +0900 Subject: Add deprecated comment support for eclipse. --- .../lombok/eclipse/agent/PatchDelegate.java | 2 +- .../resource/after-ecj/DelegateWithDeprecated.java | 41 ++++++++++------------ 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java index 87335b4e..6977df2b 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java +++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java @@ -581,7 +581,7 @@ public class PatchDelegate { method.modifiers = ClassFileConstants.AccPublic; method.returnType = makeType(binding.returnType, source, false); - boolean isDeprecated = hasDeprecatedAnnotation(binding); + boolean isDeprecated = hasDeprecatedAnnotation(binding) || binding.isDeprecated(); method.selector = binding.selector; diff --git a/test/transform/resource/after-ecj/DelegateWithDeprecated.java b/test/transform/resource/after-ecj/DelegateWithDeprecated.java index 04e12160..2a4fdf98 100644 --- a/test/transform/resource/after-ecj/DelegateWithDeprecated.java +++ b/test/transform/resource/after-ecj/DelegateWithDeprecated.java @@ -1,24 +1,21 @@ +import lombok.Delegate; 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(); - } + 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(); + } } \ No newline at end of file -- cgit From 07996af82a1fdb984659c758ad4530840789a2a1 Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Sat, 25 Feb 2012 00:02:18 +0900 Subject: Add my name to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index ebcaa916..e4295f33 100644 --- a/AUTHORS +++ b/AUTHORS @@ -6,5 +6,6 @@ Robbert Jan Grootjans Roel Spilker Sander Koning Jappe van der Hel +Taiki Sugawara 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. -- cgit From 73dab3e96613521b8769b29e6a3c7e4ee5f26911 Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Sat, 25 Feb 2012 00:11:57 +0900 Subject: Handle deprecated by ordinary usage. --- src/core/lombok/javac/handlers/HandleDelegate.java | 2 +- .../lombok/eclipse/agent/PatchDelegate.java | 18 ++---------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java index 25f29698..b1b1ecc6 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/src/core/lombok/javac/handlers/HandleDelegate.java @@ -330,7 +330,7 @@ public class HandleDelegate extends JavacAnnotationHandler { 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 || (member.flags() & DEPRECATED) != 0; + boolean isDeprecated = (member.flags() & DEPRECATED) != 0; signatures.add(new MethodSig(member.name, methodType, isDeprecated, exElem)); } diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java index 6977df2b..acf1589d 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java +++ b/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.TypeDeclaration; 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 @@ public class PatchDelegate { } } - 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 @@ public class PatchDelegate { method.modifiers = ClassFileConstants.AccPublic; method.returnType = makeType(binding.returnType, source, false); - boolean isDeprecated = hasDeprecatedAnnotation(binding) || binding.isDeprecated(); + boolean isDeprecated = binding.isDeprecated(); method.selector = binding.selector; -- cgit From b01f5aba871bc84945031d6f2322fddf4ede4543 Mon Sep 17 00:00:00 2001 From: Taiki Sugawara Date: Sat, 25 Feb 2012 01:30:20 +0900 Subject: Use english locale on test via delombok for using english message catalog. --- test/core/src/lombok/RunTestsViaDelombok.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index bde74434..a8f88757 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -56,6 +56,12 @@ public class RunTestsViaDelombok extends AbstractRunTests { delombok.addFile(file.getAbsoluteFile().getParentFile(), file.getName()); delombok.setSourcepath(file.getAbsoluteFile().getParent()); delombok.setWriter(result); - delombok.delombok(); + Locale originalLocale = Locale.getDefault(); + Locale.setDefault(Locale.ENGLISH); + try { + delombok.delombok(); + } finally { + Locale.setDefault(originalLocale); + } } } -- cgit From 6c5ca79942391d13b59a0d80d45873690af8e446 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 5 Mar 2012 20:22:27 +0100 Subject: Issue 349: Test failed in some environments --- test/core/src/lombok/RunTestsViaDelombok.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java index a8f88757..52653e2e 100644 --- a/test/core/src/lombok/RunTestsViaDelombok.java +++ b/test/core/src/lombok/RunTestsViaDelombok.java @@ -57,8 +57,8 @@ public class RunTestsViaDelombok extends AbstractRunTests { delombok.setSourcepath(file.getAbsoluteFile().getParent()); delombok.setWriter(result); Locale originalLocale = Locale.getDefault(); - Locale.setDefault(Locale.ENGLISH); try { + Locale.setDefault(Locale.ENGLISH); delombok.delombok(); } finally { Locale.setDefault(originalLocale); -- cgit From 1ac79bf86b3a11f34ad7f154f1062541052b114d Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 5 Mar 2012 20:29:12 +0100 Subject: Updated changelog --- doc/changelog.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 9499638b..f0af721c 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -7,6 +7,7 @@ Lombok Changelog * BUGFIX: Using `val` with a type like `Outer.Inner` now works. [Issue #343](http://code.google.com/p/projectlombok/issues/detail?id=343) * BUGFIX: `@Getter(lazy=true)` where the variable type is a primitive and the initializing expression is of a different primitive type that would type coerce implicitly, i.e. ints can be assigned to longs without a cast, didn't work before. [Issue #345](http://code.google.com/p/projectlombok/issues/detail?id=345) * BUGFIX: `val` is no longer legal inside basic for loops (the old kind, not the foreach kind). These variables should rarely be final, and in practice it wasn't possible to delombok this code properly. [Issue #346](http://code.google.com/p/projectlombok/issues/detail?id=346) +* BUGFIX: @Delegate would not generate @Deprecated on methods marked deprecated in javadoc [Issue #348](http://code.google.com/p/projectlombok/issues/detail?id=348) ### v0.10.8 (January 19th, 2012) * FEATURE: `@Delegate` can now be used on a no-argument method, which works similarly to adding it to fields. See [documentation](http://projectlombok.org/features/Delegate.html). -- cgit