mirror of
https://github.com/tiennm99/lombok.git
synced 2026-09-02 22:17:42 +00:00
fully tested the HandleWither impl for eclipse.
This commit is contained in:
@@ -225,7 +225,7 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
|
||||
if (child.getKind() != Kind.FIELD) continue;
|
||||
FieldDeclaration childDecl = (FieldDeclaration) child.get();
|
||||
// Skip fields that start with $
|
||||
if (childDecl.name.toString().startsWith("$")) continue;
|
||||
if (childDecl.name != null && childDecl.name.length > 0 && childDecl.name[0] == '$') continue;
|
||||
long fieldFlags = childDecl.modifiers;
|
||||
// Skip static fields.
|
||||
if ((fieldFlags & ClassFileConstants.AccStatic) != 0) continue;
|
||||
@@ -243,8 +243,8 @@ public class HandleWither extends EclipseAnnotationHandler<Wither> {
|
||||
constructorCall.type = cloneSelfType(fieldNode, source);
|
||||
|
||||
Expression identityCheck = new EqualExpression(
|
||||
new SingleNameReference(field.name, p),
|
||||
createFieldAccessor(fieldNode, FieldAccess.ALWAYS_FIELD, source),
|
||||
new SingleNameReference(field.name, p),
|
||||
OperatorIds.EQUAL_EQUAL);
|
||||
ThisReference thisRef = new ThisReference(pS, pE);
|
||||
Expression conditional = new ConditionalExpression(identityCheck, thisRef, constructorCall);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
class WitherWithGenerics<T, J extends T, L extends java.lang.Number> {
|
||||
J test;
|
||||
java.util.List<L> test2;
|
||||
java.util.List<? extends L> test3;
|
||||
int $i;
|
||||
public WitherWithGenerics(J test, java.util.List<L> test2) {
|
||||
public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public WitherWithGenerics<T, J, L> withTest(final J test) {
|
||||
return this.test == test ? this : new WitherWithGenerics<T, J, L>(test, this.test2);
|
||||
return this.test == test ? this : new WitherWithGenerics<T, J, L>(test, this.test2, this.test3);
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public WitherWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
|
||||
return this.test2 == test2 ? this : new WitherWithGenerics<T, J, L>(this.test, test2);
|
||||
return this.test2 == test2 ? this : new WitherWithGenerics<T, J, L>(this.test, test2, this.test3);
|
||||
}
|
||||
@java.lang.SuppressWarnings("all")
|
||||
public WitherWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
|
||||
return this.test3 == test3 ? this : new WitherWithGenerics<T, J, L>(this.test, this.test2, test3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,20 @@
|
||||
//ignore
|
||||
@lombok.AllArgsConstructor class WitherAndAllArgsConstructor<T, J extends T, L extends java.lang.Number> {
|
||||
@lombok.experimental.Wither J test;
|
||||
@lombok.experimental.Wither java.util.List<L> test2;
|
||||
final int x = 10;
|
||||
int y = 20;
|
||||
final int z;
|
||||
public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor<T, J, L> withTest(final J test) {
|
||||
return ((this.test == test) ? this : new WitherAndAllArgsConstructor<T, J, L>(test, this.test2, this.y, this.z));
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WitherAndAllArgsConstructor<T, J, L> withTest2(final java.util.List<L> test2) {
|
||||
return ((this.test2 == test2) ? this : new WitherAndAllArgsConstructor<T, J, L>(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<L> test2, final int y, final int z) {
|
||||
super();
|
||||
this.test = test;
|
||||
this.test2 = test2;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
//ignore
|
||||
class WitherOnStatic {
|
||||
static @lombok.experimental.Wither boolean foo;
|
||||
static @lombok.experimental.Wither int bar;
|
||||
<clinit>() {
|
||||
}
|
||||
WitherOnStatic() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,6 @@
|
||||
//ignore
|
||||
class WitherWithDollar {
|
||||
@lombok.experimental.Wither int $i;
|
||||
WitherWithDollar() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
//ignore
|
||||
class WitherWithGenerics<T, J extends T, L extends java.lang.Number> {
|
||||
@lombok.experimental.Wither J test;
|
||||
@lombok.experimental.Wither java.util.List<L> test2;
|
||||
@lombok.experimental.Wither java.util.List<? extends L> test3;
|
||||
int $i;
|
||||
public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
|
||||
super();
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest(final J test) {
|
||||
return ((this.test == test) ? this : new WitherWithGenerics<T, J, L>(test, this.test2, this.test3));
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest2(final java.util.List<L> test2) {
|
||||
return ((this.test2 == test2) ? this : new WitherWithGenerics<T, J, L>(this.test, test2, this.test3));
|
||||
}
|
||||
public @java.lang.SuppressWarnings("all") WitherWithGenerics<T, J, L> withTest3(final java.util.List<? extends L> test3) {
|
||||
return ((this.test3 == test3) ? this : new WitherWithGenerics<T, J, L>(this.test, this.test2, test3));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,7 @@ class WitherPlain {
|
||||
@Wither final int foo;
|
||||
|
||||
WitherPlain(int i, int foo) {
|
||||
this.i = i;
|
||||
this.foo = foo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
class WitherWithGenerics<T, J extends T, L extends java.lang.Number> {
|
||||
@lombok.experimental.Wither J test;
|
||||
@lombok.experimental.Wither java.util.List<L> test2;
|
||||
@lombok.experimental.Wither java.util.List<? extends L> test3;
|
||||
int $i;
|
||||
|
||||
public WitherWithGenerics(J test, java.util.List<L> test2) {
|
||||
public WitherWithGenerics(J test, java.util.List<L> test2, java.util.List<? extends L> test3) {
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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.
|
||||
@@ -0,0 +1 @@
|
||||
2 warning Not generating wither for this field: Withers cannot be generated for fields starting with $.
|
||||
Reference in New Issue
Block a user