From 8ca3ddaa530ca287caff32c2b0dbcff8c17e74c2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 6 Aug 2012 21:26:55 +0200 Subject: fully tested the HandleWither impl for eclipse. --- .../resource/after-delombok/WitherPlain.java | 2 + .../after-delombok/WitherWithGenerics.java | 11 ++- .../resource/after-ecj/WitherAccessLevel.java | 28 +++++++- .../resource/after-ecj/WitherAlreadyExists.java | 79 +++++++++++++++++++++- .../after-ecj/WitherAndAllArgsConstructor.java | 21 +++++- .../resource/after-ecj/WitherDeprecated.java | 15 +++- .../resource/after-ecj/WitherOnClass.java | 51 +++++++++++++- .../resource/after-ecj/WitherOnStatic.java | 10 ++- test/transform/resource/after-ecj/WitherPlain.java | 17 ++++- .../resource/after-ecj/WitherWithDollar.java | 7 +- .../resource/after-ecj/WitherWithGenerics.java | 19 +++++- test/transform/resource/before/WitherPlain.java | 2 + .../resource/before/WitherWithGenerics.java | 3 +- .../messages-ecj/SetterAlreadyExists.java.messages | 12 ++-- .../messages-ecj/WitherAlreadyExists.java.messages | 7 ++ .../messages-ecj/WitherOnStatic.java.messages | 2 + .../messages-ecj/WitherWithDollar.java.messages | 1 + 17 files changed, 268 insertions(+), 19 deletions(-) create mode 100644 test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages create mode 100644 test/transform/resource/messages-ecj/WitherOnStatic.java.messages create mode 100644 test/transform/resource/messages-ecj/WitherWithDollar.java.messages (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/WitherPlain.java b/test/transform/resource/after-delombok/WitherPlain.java index ab6a3f4b..a2e947bd 100644 --- a/test/transform/resource/after-delombok/WitherPlain.java +++ b/test/transform/resource/after-delombok/WitherPlain.java @@ -2,6 +2,8 @@ class WitherPlain { int i; final int foo; WitherPlain(int i, int foo) { + this.i = i; + this.foo = foo; } @java.lang.SuppressWarnings("all") public WitherPlain withI(final int i) { diff --git a/test/transform/resource/after-delombok/WitherWithGenerics.java b/test/transform/resource/after-delombok/WitherWithGenerics.java index 9630c792..98bbd04d 100644 --- a/test/transform/resource/after-delombok/WitherWithGenerics.java +++ b/test/transform/resource/after-delombok/WitherWithGenerics.java @@ -1,15 +1,20 @@ class WitherWithGenerics { J test; java.util.List test2; + java.util.List test3; int $i; - public WitherWithGenerics(J test, java.util.List test2) { + public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { } @java.lang.SuppressWarnings("all") public WitherWithGenerics withTest(final J test) { - return this.test == test ? this : new WitherWithGenerics(test, this.test2); + return this.test == test ? this : new WitherWithGenerics(test, this.test2, this.test3); } @java.lang.SuppressWarnings("all") public WitherWithGenerics withTest2(final java.util.List test2) { - return this.test2 == test2 ? this : new WitherWithGenerics(this.test, test2); + return this.test2 == test2 ? this : new WitherWithGenerics(this.test, test2, this.test3); + } + @java.lang.SuppressWarnings("all") + public WitherWithGenerics withTest3(final java.util.List test3) { + return this.test3 == test3 ? this : new WitherWithGenerics(this.test, this.test2, test3); } } diff --git a/test/transform/resource/after-ecj/WitherAccessLevel.java b/test/transform/resource/after-ecj/WitherAccessLevel.java index 0facc12f..09a2e514 100644 --- a/test/transform/resource/after-ecj/WitherAccessLevel.java +++ b/test/transform/resource/after-ecj/WitherAccessLevel.java @@ -1 +1,27 @@ -//ignore +import lombok.AccessLevel; +class WitherAccessLevel { + @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; + @lombok.experimental.Wither(AccessLevel.PRIVATE) boolean isPrivate; + @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) boolean isPackage; + @lombok.experimental.Wither(AccessLevel.PROTECTED) boolean isProtected; + @lombok.experimental.Wither(lombok.AccessLevel.PUBLIC) boolean isPublic; + @lombok.experimental.Wither(value = lombok.AccessLevel.PUBLIC) boolean value; + WitherAccessLevel(boolean isNone, boolean isPrivate, boolean isPackage, boolean isProtected, boolean isPublic, boolean value) { + super(); + } + private @java.lang.SuppressWarnings("all") WitherAccessLevel withPrivate(final boolean isPrivate) { + return ((this.isPrivate == isPrivate) ? this : new WitherAccessLevel(this.isNone, isPrivate, this.isPackage, this.isProtected, this.isPublic, this.value)); + } + @java.lang.SuppressWarnings("all") WitherAccessLevel withPackage(final boolean isPackage) { + return ((this.isPackage == isPackage) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, isPackage, this.isProtected, this.isPublic, this.value)); + } + protected @java.lang.SuppressWarnings("all") WitherAccessLevel withProtected(final boolean isProtected) { + return ((this.isProtected == isProtected) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, isProtected, this.isPublic, this.value)); + } + public @java.lang.SuppressWarnings("all") WitherAccessLevel withPublic(final boolean isPublic) { + return ((this.isPublic == isPublic) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, isPublic, this.value)); + } + public @java.lang.SuppressWarnings("all") WitherAccessLevel withValue(final boolean value) { + return ((this.value == value) ? this : new WitherAccessLevel(this.isNone, this.isPrivate, this.isPackage, this.isProtected, this.isPublic, value)); + } +} diff --git a/test/transform/resource/after-ecj/WitherAlreadyExists.java b/test/transform/resource/after-ecj/WitherAlreadyExists.java index 0facc12f..ded10755 100644 --- a/test/transform/resource/after-ecj/WitherAlreadyExists.java +++ b/test/transform/resource/after-ecj/WitherAlreadyExists.java @@ -1 +1,78 @@ -//ignore +class Wither1 { + @lombok.experimental.Wither boolean foo; + void withFoo(boolean foo) { + } + Wither1(boolean foo) { + super(); + } +} +class Wither2 { + @lombok.experimental.Wither boolean foo; + void withFoo(String foo) { + } + Wither2(boolean foo) { + super(); + } +} +class Wither3 { + @lombok.experimental.Wither String foo; + void withFoo(boolean foo) { + } + Wither3(String foo) { + super(); + } +} +class Wither4 { + @lombok.experimental.Wither String foo; + void withFoo(String foo) { + } + Wither4(String foo) { + super(); + } +} +class Wither5 { + @lombok.experimental.Wither String foo; + void withFoo() { + } + Wither5(String foo) { + super(); + } + public @java.lang.SuppressWarnings("all") Wither5 withFoo(final String foo) { + return ((this.foo == foo) ? this : new Wither5(foo)); + } +} +class Wither6 { + @lombok.experimental.Wither String foo; + void withFoo(String foo, int x) { + } + Wither6(String foo) { + super(); + } + public @java.lang.SuppressWarnings("all") Wither6 withFoo(final String foo) { + return ((this.foo == foo) ? this : new Wither6(foo)); + } +} +class Wither7 { + @lombok.experimental.Wither String foo; + void withFoo(String foo, Object... x) { + } + Wither7(String foo) { + super(); + } +} +class Wither8 { + @lombok.experimental.Wither boolean isFoo; + void withIsFoo(boolean foo) { + } + Wither8(boolean foo) { + super(); + } +} +class Wither9 { + @lombok.experimental.Wither boolean isFoo; + void withFoo(boolean foo) { + } + Wither9(boolean foo) { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java b/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java index 0facc12f..091024e2 100644 --- a/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java +++ b/test/transform/resource/after-ecj/WitherAndAllArgsConstructor.java @@ -1 +1,20 @@ -//ignore +@lombok.AllArgsConstructor class WitherAndAllArgsConstructor { + @lombok.experimental.Wither J test; + @lombok.experimental.Wither java.util.List test2; + final int x = 10; + int y = 20; + final int z; + public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor withTest(final J test) { + return ((this.test == test) ? this : new WitherAndAllArgsConstructor(test, this.test2, this.y, this.z)); + } + public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor withTest2(final java.util.List test2) { + return ((this.test2 == test2) ? this : new WitherAndAllArgsConstructor(this.test, test2, this.y, this.z)); + } + public @java.beans.ConstructorProperties({"test", "test2", "y", "z"}) @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor(final J test, final java.util.List test2, final int y, final int z) { + super(); + this.test = test; + this.test2 = test2; + this.y = y; + this.z = z; + } +} diff --git a/test/transform/resource/after-ecj/WitherDeprecated.java b/test/transform/resource/after-ecj/WitherDeprecated.java index 0facc12f..b57d0d79 100644 --- a/test/transform/resource/after-ecj/WitherDeprecated.java +++ b/test/transform/resource/after-ecj/WitherDeprecated.java @@ -1 +1,14 @@ -//ignore +import lombok.experimental.Wither; +class WitherDeprecated { + @Deprecated @Wither int annotation; + @Wither int javadoc; + WitherDeprecated(int annotation, int javadoc) { + super(); + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WitherDeprecated withAnnotation(final int annotation) { + return ((this.annotation == annotation) ? this : new WitherDeprecated(annotation, this.javadoc)); + } + public @java.lang.Deprecated @java.lang.SuppressWarnings("all") WitherDeprecated withJavadoc(final int javadoc) { + return ((this.javadoc == javadoc) ? this : new WitherDeprecated(this.annotation, javadoc)); + } +} diff --git a/test/transform/resource/after-ecj/WitherOnClass.java b/test/transform/resource/after-ecj/WitherOnClass.java index 0facc12f..ff4566e5 100644 --- a/test/transform/resource/after-ecj/WitherOnClass.java +++ b/test/transform/resource/after-ecj/WitherOnClass.java @@ -1 +1,50 @@ -//ignore +@lombok.experimental.Wither class WitherOnClass1 { + @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; + boolean isPublic; + WitherOnClass1(boolean isNone, boolean isPublic) { + super(); + } + public @java.lang.SuppressWarnings("all") WitherOnClass1 withPublic(final boolean isPublic) { + return ((this.isPublic == isPublic) ? this : new WitherOnClass1(this.isNone, isPublic)); + } +} +@lombok.experimental.Wither(lombok.AccessLevel.PROTECTED) class WitherOnClass2 { + @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; + boolean isProtected; + @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) boolean isPackage; + WitherOnClass2(boolean isNone, boolean isProtected, boolean isPackage) { + super(); + } + @java.lang.SuppressWarnings("all") WitherOnClass2 withPackage(final boolean isPackage) { + return ((this.isPackage == isPackage) ? this : new WitherOnClass2(this.isNone, this.isProtected, isPackage)); + } + protected @java.lang.SuppressWarnings("all") WitherOnClass2 withProtected(final boolean isProtected) { + return ((this.isProtected == isProtected) ? this : new WitherOnClass2(this.isNone, isProtected, this.isPackage)); + } +} +@lombok.experimental.Wither class WitherOnClass3 { + String couldBeNull; + @lombok.NonNull String nonNull; + WitherOnClass3(String couldBeNull, String nonNull) { + super(); + } + public @java.lang.SuppressWarnings("all") WitherOnClass3 withCouldBeNull(final String couldBeNull) { + return ((this.couldBeNull == couldBeNull) ? this : new WitherOnClass3(couldBeNull, this.nonNull)); + } + public @java.lang.SuppressWarnings("all") WitherOnClass3 withNonNull(final @lombok.NonNull String nonNull) { + if ((nonNull == null)) + throw new java.lang.NullPointerException("nonNull"); + return ((this.nonNull == nonNull) ? this : new WitherOnClass3(this.couldBeNull, nonNull)); + } +} +@lombok.experimental.Wither @lombok.experimental.Accessors(prefix = "f") class WitherOnClass4 { + final int fX = 10; + final int fY; + WitherOnClass4(int y) { + super(); + this.fY = y; + } + public @java.lang.SuppressWarnings("all") WitherOnClass4 withY(final int fY) { + return ((this.fY == fY) ? this : new WitherOnClass4(fY)); + } +} diff --git a/test/transform/resource/after-ecj/WitherOnStatic.java b/test/transform/resource/after-ecj/WitherOnStatic.java index 0facc12f..8f385e09 100644 --- a/test/transform/resource/after-ecj/WitherOnStatic.java +++ b/test/transform/resource/after-ecj/WitherOnStatic.java @@ -1 +1,9 @@ -//ignore +class WitherOnStatic { + static @lombok.experimental.Wither boolean foo; + static @lombok.experimental.Wither int bar; + () { + } + WitherOnStatic() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WitherPlain.java b/test/transform/resource/after-ecj/WitherPlain.java index 0facc12f..ae1988bc 100644 --- a/test/transform/resource/after-ecj/WitherPlain.java +++ b/test/transform/resource/after-ecj/WitherPlain.java @@ -1 +1,16 @@ -//ignore +import lombok.experimental.Wither; +class WitherPlain { + @lombok.experimental.Wither int i; + final @Wither int foo; + WitherPlain(int i, int foo) { + super(); + this.i = i; + this.foo = foo; + } + public @java.lang.SuppressWarnings("all") WitherPlain withI(final int i) { + return ((this.i == i) ? this : new WitherPlain(i, this.foo)); + } + public @java.lang.SuppressWarnings("all") WitherPlain withFoo(final int foo) { + return ((this.foo == foo) ? this : new WitherPlain(this.i, foo)); + } +} diff --git a/test/transform/resource/after-ecj/WitherWithDollar.java b/test/transform/resource/after-ecj/WitherWithDollar.java index 0facc12f..db46e259 100644 --- a/test/transform/resource/after-ecj/WitherWithDollar.java +++ b/test/transform/resource/after-ecj/WitherWithDollar.java @@ -1 +1,6 @@ -//ignore +class WitherWithDollar { + @lombok.experimental.Wither int $i; + WitherWithDollar() { + super(); + } +} diff --git a/test/transform/resource/after-ecj/WitherWithGenerics.java b/test/transform/resource/after-ecj/WitherWithGenerics.java index 0facc12f..ee73297c 100644 --- a/test/transform/resource/after-ecj/WitherWithGenerics.java +++ b/test/transform/resource/after-ecj/WitherWithGenerics.java @@ -1 +1,18 @@ -//ignore +class WitherWithGenerics { + @lombok.experimental.Wither J test; + @lombok.experimental.Wither java.util.List test2; + @lombok.experimental.Wither java.util.List test3; + int $i; + public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { + super(); + } + public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest(final J test) { + return ((this.test == test) ? this : new WitherWithGenerics(test, this.test2, this.test3)); + } + public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest2(final java.util.List test2) { + return ((this.test2 == test2) ? this : new WitherWithGenerics(this.test, test2, this.test3)); + } + public @java.lang.SuppressWarnings("all") WitherWithGenerics withTest3(final java.util.List test3) { + return ((this.test3 == test3) ? this : new WitherWithGenerics(this.test, this.test2, test3)); + } +} diff --git a/test/transform/resource/before/WitherPlain.java b/test/transform/resource/before/WitherPlain.java index 7f931217..436e6f3b 100644 --- a/test/transform/resource/before/WitherPlain.java +++ b/test/transform/resource/before/WitherPlain.java @@ -4,5 +4,7 @@ class WitherPlain { @Wither final int foo; WitherPlain(int i, int foo) { + this.i = i; + this.foo = foo; } } diff --git a/test/transform/resource/before/WitherWithGenerics.java b/test/transform/resource/before/WitherWithGenerics.java index 229cc94e..0b0fdd46 100644 --- a/test/transform/resource/before/WitherWithGenerics.java +++ b/test/transform/resource/before/WitherWithGenerics.java @@ -1,8 +1,9 @@ class WitherWithGenerics { @lombok.experimental.Wither J test; @lombok.experimental.Wither java.util.List test2; + @lombok.experimental.Wither java.util.List test3; int $i; - public WitherWithGenerics(J test, java.util.List test2) { + public WitherWithGenerics(J test, java.util.List test2, java.util.List test3) { } } \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages b/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages index bc97510c..d33024db 100644 --- a/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages @@ -1,7 +1,7 @@ 2 warning Not generating setFoo(): A method with that name already exists -7 warning Not generating setFoo(): A method with that name already exists -12 warning Not generating setFoo(): A method with that name already exists -17 warning Not generating setFoo(): A method with that name already exists -32 warning Not generating setFoo(): A method with that name already exists -37 warning Not generating setFoo(): A method with that name already exists (setIsFoo) -42 warning Not generating setFoo(): A method with that name already exists +8 warning Not generating setFoo(): A method with that name already exists +14 warning Not generating setFoo(): A method with that name already exists +20 warning Not generating setFoo(): A method with that name already exists +38 warning Not generating setFoo(): A method with that name already exists +44 warning Not generating setFoo(): A method with that name already exists (setIsFoo) +50 warning Not generating setFoo(): A method with that name already exists \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages b/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages new file mode 100644 index 00000000..bba8913b --- /dev/null +++ b/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages @@ -0,0 +1,7 @@ +2 warning Not generating withFoo(): A method with that name already exists +12 warning Not generating withFoo(): A method with that name already exists +22 warning Not generating withFoo(): A method with that name already exists +32 warning Not generating withFoo(): A method with that name already exists +62 warning Not generating withFoo(): A method with that name already exists +72 warning Not generating withFoo(): A method with that name already exists (withIsFoo) +82 warning Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/WitherOnStatic.java.messages b/test/transform/resource/messages-ecj/WitherOnStatic.java.messages new file mode 100644 index 00000000..5b52d54f --- /dev/null +++ b/test/transform/resource/messages-ecj/WitherOnStatic.java.messages @@ -0,0 +1,2 @@ +2 warning Not generating wither for this field: Withers cannot be generated for static fields. +3 warning Not generating wither for this field: Withers cannot be generated for static fields. diff --git a/test/transform/resource/messages-ecj/WitherWithDollar.java.messages b/test/transform/resource/messages-ecj/WitherWithDollar.java.messages new file mode 100644 index 00000000..e55530e3 --- /dev/null +++ b/test/transform/resource/messages-ecj/WitherWithDollar.java.messages @@ -0,0 +1 @@ +2 warning Not generating wither for this field: Withers cannot be generated for fields starting with $. -- cgit