diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 22:04:39 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-07-16 22:04:39 +0200 |
commit | e6421509987c01e06b7c79ef406cc01ff174ae81 (patch) | |
tree | fd86dd5dcdc258c3927b778dc23e01d3ea652e62 | |
parent | 2502862f896d11b9e386df34f6891918ed443409 (diff) | |
download | lombok-e6421509987c01e06b7c79ef406cc01ff174ae81.tar.gz lombok-e6421509987c01e06b7c79ef406cc01ff174ae81.tar.bz2 lombok-e6421509987c01e06b7c79ef406cc01ff174ae81.zip |
Updated tests to reflect changes to delombok (delombok now kills super(), because attrib adds them even in places where that's wrong).
Also split up the SynchronizedName test into separate cases for each expected failure mode.
14 files changed, 54 insertions, 19 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 095928ad..2f47ccf6 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -1037,8 +1037,17 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { throw new UncheckedIOException(e); } } - + + private boolean isNoArgsSuperCall(JCExpression expr) { + if (!(expr instanceof JCMethodInvocation)) return false; + JCMethodInvocation tree = (JCMethodInvocation) expr; + if (!tree.typeargs.isEmpty() || !tree.args.isEmpty()) return false; + if (!(tree.meth instanceof JCIdent)) return false; + return ((JCIdent) tree.meth).name.toString().equals("super"); + } + public void visitExec(JCExpressionStatement tree) { + if (isNoArgsSuperCall(tree.expr)) return; try { printExpr(tree.expr); if (prec == TreeInfo.notExpression) print(";"); diff --git a/test/transform/resource/after-delombok/DataPlain.java b/test/transform/resource/after-delombok/DataPlain.java index cb002e07..a8cb37af 100644 --- a/test/transform/resource/after-delombok/DataPlain.java +++ b/test/transform/resource/after-delombok/DataPlain.java @@ -155,7 +155,6 @@ final class Data3 { final class Data4 extends java.util.Timer { int x; Data4() { - super(); } @java.lang.SuppressWarnings("all") public int getX() { diff --git a/test/transform/resource/after-delombok/SneakyThrowsPlain.java b/test/transform/resource/after-delombok/SneakyThrowsPlain.java index 5c0890b5..f712ab55 100644 --- a/test/transform/resource/after-delombok/SneakyThrowsPlain.java +++ b/test/transform/resource/after-delombok/SneakyThrowsPlain.java @@ -1,6 +1,5 @@ class SneakyThrowsPlain { SneakyThrowsPlain() { - super(); try { System.out.println("constructor"); } catch (final java.lang.Throwable $ex) { diff --git a/test/transform/resource/after-delombok/SynchronizedName.java b/test/transform/resource/after-delombok/SynchronizedName.java index e7dd23ff..ab3c0431 100644 --- a/test/transform/resource/after-delombok/SynchronizedName.java +++ b/test/transform/resource/after-delombok/SynchronizedName.java @@ -1,19 +1,12 @@ class SynchronizedName { private Object read = new Object(); private static Object READ = new Object(); + void test1() { synchronized (this.read) { System.out.println("one"); } } - void test2() { - System.out.println("two"); - } - static void test3() { - synchronized (SynchronizedName.read) { - System.out.println("three"); - } - } void test4() { synchronized (this.READ) { System.out.println("four"); @@ -24,4 +17,4 @@ class SynchronizedName { System.out.println("five"); } } -} +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/SynchronizedNameNoSuchField.java b/test/transform/resource/after-delombok/SynchronizedNameNoSuchField.java new file mode 100644 index 00000000..d252985f --- /dev/null +++ b/test/transform/resource/after-delombok/SynchronizedNameNoSuchField.java @@ -0,0 +1,7 @@ +class SynchronizedNameNoSuchField { + private Object read = new Object(); + private static Object READ = new Object(); + void test2() { + System.out.println("two"); + } +}
\ No newline at end of file diff --git a/test/transform/resource/after-delombok/SynchronizedNameStaticToInstanceRef.java b/test/transform/resource/after-delombok/SynchronizedNameStaticToInstanceRef.java new file mode 100644 index 00000000..8441570b --- /dev/null +++ b/test/transform/resource/after-delombok/SynchronizedNameStaticToInstanceRef.java @@ -0,0 +1,9 @@ +class SynchronizedNameStaticToInstanceRef { + private Object read = new Object(); + private static Object READ = new Object(); + static void test3() { + synchronized (SynchronizedNameStaticToInstanceRef.read) { + System.out.println("three"); + } + } +}
\ No newline at end of file diff --git a/test/transform/resource/before/SynchronizedName.java b/test/transform/resource/before/SynchronizedName.java index 5d074113..7553a8ce 100644 --- a/test/transform/resource/before/SynchronizedName.java +++ b/test/transform/resource/before/SynchronizedName.java @@ -5,12 +5,6 @@ class SynchronizedName { @lombok.Synchronized("read") void test1() { System.out.println("one"); } - @lombok.Synchronized("write") void test2() { - System.out.println("two"); - } - @lombok.Synchronized("read") static void test3() { - System.out.println("three"); - } @lombok.Synchronized("READ") void test4() { System.out.println("four"); } diff --git a/test/transform/resource/before/SynchronizedNameNoSuchField.java b/test/transform/resource/before/SynchronizedNameNoSuchField.java new file mode 100644 index 00000000..343ba6ae --- /dev/null +++ b/test/transform/resource/before/SynchronizedNameNoSuchField.java @@ -0,0 +1,8 @@ +class SynchronizedNameNoSuchField { + private Object read = new Object(); + private static Object READ = new Object(); + + @lombok.Synchronized("write") void test2() { + System.out.println("two"); + } +} diff --git a/test/transform/resource/before/SynchronizedNameStaticToInstanceRef.java b/test/transform/resource/before/SynchronizedNameStaticToInstanceRef.java new file mode 100644 index 00000000..08f9dbf1 --- /dev/null +++ b/test/transform/resource/before/SynchronizedNameStaticToInstanceRef.java @@ -0,0 +1,8 @@ +class SynchronizedNameStaticToInstanceRef { + private Object read = new Object(); + private static Object READ = new Object(); + + @lombok.Synchronized("read") static void test3() { + System.out.println("three"); + } +} diff --git a/test/transform/resource/messages-delombok/SynchronizedName.java.messages b/test/transform/resource/messages-delombok/SynchronizedName.java.messages deleted file mode 100644 index 2af3ca1d..00000000 --- a/test/transform/resource/messages-delombok/SynchronizedName.java.messages +++ /dev/null @@ -1 +0,0 @@ -8:9 ERROR The field write does not exist.
\ No newline at end of file diff --git a/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages b/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages new file mode 100644 index 00000000..bffd29e6 --- /dev/null +++ b/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages @@ -0,0 +1 @@ +5:9 ERROR The field write does not exist. diff --git a/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages b/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages new file mode 100644 index 00000000..1a084653 --- /dev/null +++ b/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages @@ -0,0 +1 @@ +-1:-1 ERROR non-static variable read cannot be referenced from a static context diff --git a/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages b/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages new file mode 100644 index 00000000..c34e29f6 --- /dev/null +++ b/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages @@ -0,0 +1 @@ +5:66 ERROR non-static variable read cannot be referenced from a static context diff --git a/test/transform/resource/messages-idempotent/ValErrors.java.messages b/test/transform/resource/messages-idempotent/ValErrors.java.messages new file mode 100644 index 00000000..6f666511 --- /dev/null +++ b/test/transform/resource/messages-idempotent/ValErrors.java.messages @@ -0,0 +1,7 @@ +3:44 ERROR cannot find symbol +symbol : variable d +location: class ValErrors +6:17 ERROR cannot find symbol +symbol : class val +location: class ValErrors +6:25 ERROR illegal initializer for <none> |