From 2fd46a50b6125fd9f0e8177ffad5db8ee934fe34 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 1 Nov 2018 16:38:25 +0100 Subject: [feature] FieldNameConstants now works like Builder: Make whatever bits it does by hand and lombok fills in whatever is missing. --- .../after-delombok/FieldNameConstantsBasic.java | 2 +- .../FieldNameConstantsHandrolled.java | 30 +++++++++++ .../after-ecj/FieldNameConstantsBasic.java | 2 +- .../after-ecj/FieldNameConstantsHandrolled.java | 59 ++++++++++++++++++++++ .../before/FieldNameConstantsHandrolled.java | 33 ++++++++++++ 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 test/transform/resource/after-delombok/FieldNameConstantsHandrolled.java create mode 100644 test/transform/resource/after-ecj/FieldNameConstantsHandrolled.java create mode 100644 test/transform/resource/before/FieldNameConstantsHandrolled.java (limited to 'test/transform') diff --git a/test/transform/resource/after-delombok/FieldNameConstantsBasic.java b/test/transform/resource/after-delombok/FieldNameConstantsBasic.java index 8be45d2b..0504327a 100644 --- a/test/transform/resource/after-delombok/FieldNameConstantsBasic.java +++ b/test/transform/resource/after-delombok/FieldNameConstantsBasic.java @@ -6,7 +6,7 @@ public class FieldNameConstantsBasic { String butPrintMePlease; @java.lang.SuppressWarnings("all") static final class Fields { - public static final java.lang.String butPrintMePlease = "butPrintMePlease"; public static final java.lang.String iAmADvdPlayer = "iAmADvdPlayer"; + public static final java.lang.String butPrintMePlease = "butPrintMePlease"; } } diff --git a/test/transform/resource/after-delombok/FieldNameConstantsHandrolled.java b/test/transform/resource/after-delombok/FieldNameConstantsHandrolled.java new file mode 100644 index 00000000..2677cfa0 --- /dev/null +++ b/test/transform/resource/after-delombok/FieldNameConstantsHandrolled.java @@ -0,0 +1,30 @@ +class FieldNameConstantsHandrolled1 { + int field1; + int alsoAField; + int thirdField; + public enum TypeTest { + alsoAField, thirdField, field1; + } +} +class FieldNameConstantsHandrolled2 { + int field1; + int alsoAField; + int thirdField; + public enum TypeTest { + alsoAField, thirdField, field1; + public String foo() { + return name(); + } + } +} + +class FieldNameConstantsHandrolled3 { + int field1; + int alsoAField; + int thirdField; + static class Fields { + public static final java.lang.String field1 = "field1"; + public static final java.lang.String thirdField = "thirdField"; + public static final int alsoAField = 5; + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/FieldNameConstantsBasic.java b/test/transform/resource/after-ecj/FieldNameConstantsBasic.java index 674dd602..5b58e7d7 100644 --- a/test/transform/resource/after-ecj/FieldNameConstantsBasic.java +++ b/test/transform/resource/after-ecj/FieldNameConstantsBasic.java @@ -2,8 +2,8 @@ import lombok.experimental.FieldNameConstants; import lombok.AccessLevel; public @FieldNameConstants(level = AccessLevel.PACKAGE) class FieldNameConstantsBasic { static final @java.lang.SuppressWarnings("all") class Fields { - public static final java.lang.String butPrintMePlease = "butPrintMePlease"; public static final java.lang.String iAmADvdPlayer = "iAmADvdPlayer"; + public static final java.lang.String butPrintMePlease = "butPrintMePlease"; () { } private @java.lang.SuppressWarnings("all") Fields() { diff --git a/test/transform/resource/after-ecj/FieldNameConstantsHandrolled.java b/test/transform/resource/after-ecj/FieldNameConstantsHandrolled.java new file mode 100644 index 00000000..6762fdd8 --- /dev/null +++ b/test/transform/resource/after-ecj/FieldNameConstantsHandrolled.java @@ -0,0 +1,59 @@ +import lombok.experimental.FieldNameConstants; +import lombok.AccessLevel; +@FieldNameConstants(asEnum = true,innerTypeName = "TypeTest") class FieldNameConstantsHandrolled1 { + public enum TypeTest { + field1(), + alsoAField(), + thirdField(), + () { + } + private @java.lang.SuppressWarnings("all") TypeTest() { + super(); + } + } + int field1; + int alsoAField; + int thirdField; + FieldNameConstantsHandrolled1() { + super(); + } +} +@FieldNameConstants(asEnum = true,innerTypeName = "TypeTest") class FieldNameConstantsHandrolled2 { + public enum TypeTest { + field1(), + alsoAField(), + thirdField(), + () { + } + public String foo() { + return name(); + } + private @java.lang.SuppressWarnings("all") TypeTest() { + super(); + } + } + int field1; + int alsoAField; + int thirdField; + FieldNameConstantsHandrolled2() { + super(); + } +} +@FieldNameConstants class FieldNameConstantsHandrolled3 { + static class Fields { + public static final java.lang.String field1 = "field1"; + public static final java.lang.String thirdField = "thirdField"; + public static final int alsoAField = 5; + () { + } + private @java.lang.SuppressWarnings("all") Fields() { + super(); + } + } + int field1; + int alsoAField; + int thirdField; + FieldNameConstantsHandrolled3() { + super(); + } +} diff --git a/test/transform/resource/before/FieldNameConstantsHandrolled.java b/test/transform/resource/before/FieldNameConstantsHandrolled.java new file mode 100644 index 00000000..b6765fb2 --- /dev/null +++ b/test/transform/resource/before/FieldNameConstantsHandrolled.java @@ -0,0 +1,33 @@ +import lombok.experimental.FieldNameConstants; +import lombok.AccessLevel; + +@FieldNameConstants(asEnum = true, innerTypeName = "TypeTest") +class FieldNameConstantsHandrolled1 { + int field1, alsoAField, thirdField; + + public enum TypeTest { + field1 + } +} + +@FieldNameConstants(asEnum = true, innerTypeName = "TypeTest") +class FieldNameConstantsHandrolled2 { + int field1, alsoAField, thirdField; + + public enum TypeTest { + field1; + + public String foo() { + return name(); + } + } +} + +@FieldNameConstants +class FieldNameConstantsHandrolled3 { + int field1, alsoAField, thirdField; + + static class Fields { + public static final int alsoAField = 5; + } +} -- cgit