aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xAUTHORS1
-rw-r--r--doc/changelog.markdown4
-rw-r--r--src/core/lombok/core/Version.java6
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleConstructor.java19
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java18
-rw-r--r--test/transform/resource/after-delombok/ValueStaticConstructorOf.java50
-rw-r--r--test/transform/resource/after-ecj/ValueStaticConstructorOf.java47
-rw-r--r--test/transform/resource/before/ValueStaticConstructorOf.java12
8 files changed, 142 insertions, 15 deletions
diff --git a/AUTHORS b/AUTHORS
index 251353a3..e77bc462 100755
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,6 +14,7 @@ Kevin Chirls <kchirls@users.noreply.github.com>
Liu DongMiao <liudongmiao@gmail.com>
Luan Nico <luannico27@gmail.com>
Maarten Mulders <mthmulders@users.noreply.github.com>
+Mark Haynes <markhaynes.work@gmail.com>
Mart Hagenaars <marthagenaars@gmail.com>
Mateusz Matela <mateusz.matela@gmail.com>
Michiel Verheul <cheelio@gmail.com>
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 561db859..e0e3d49a 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -1,6 +1,9 @@
Lombok Changelog
----------------
+### v1.18.9 "Edgy Guinea Pig"
+* Nothing yet.
+
### v1.18.8 (May 7th, 2019)
* FEATURE: You can now configure `@FieldNameConstants` to `CONSTANT_CASE` the generated constants, using a `lombok.config` option. See the [FieldNameConstants documentation](https://projectlombok.org/features/experimental/FieldNameConstants). [Issue #2092](https://github.com/rzwitserloot/lombok/issues/2092).
* FEATURE: You can now suppress generation of the `builder` method when using `@Builder`; usually because you're only interested in the `toBuilder` method. As a convenience we won't emit warnings about missing `@Builder.Default` annotations when you do this. [Issue #2046](https://github.com/rzwitserloot/lombok/issues/2046)
@@ -15,6 +18,7 @@ Lombok Changelog
* BUGFIX: `@SuperBuilder` together with `@Singular` on non-lists would produce an erroneous `emptyList` call. [Issue #2104](https://github.com/rzwitserloot/lombok/issues/2104).
* IMPROBABLE BREAKING CHANGE: For fields and parameters marked non-null, if the method body starts with an assert statement to ensure the value isn't null, no code to throw an exception will be generated.
* IMPROBABLE BREAKING CHANGE: When using `ecj` to compile java code with `@Builder` or `@SuperBuilder` in it, and a builder setter method was generated for a `@NonNull`-marked method, no explicit null check would be present. However, running `javac` on the exact same file _would_ produce the null check. Now ecj also produces this null check. [Issue #2120](https://github.com/rzwitserloot/lombok/issues/2120).
+* IMPROBABLE BREAKING CHANGE: We slightly changed the message of the exception lombok generates to handle `@NonNull` marked parameters. [Issue #2122](https://github.com/rzwitserloot/lombok/issues/2122).
### v1.18.6 (February 12th, 2019)
* FEATURE: Javadoc on fields will now also be copied to the Builders' setters. Thanks for the contribution, Emil Lundberg. [Issue #2008](https://github.com/rzwitserloot/lombok/issues/2008)
diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java
index e3d7368e..0a4f7e3d 100644
--- a/src/core/lombok/core/Version.java
+++ b/src/core/lombok/core/Version.java
@@ -30,9 +30,9 @@ public class Version {
// ** CAREFUL ** - this class must always compile with 0 dependencies (it must not refer to any other sources or libraries).
// Note: In 'X.Y.Z', if Z is odd, its a snapshot build built from the repository, so many different 0.10.3 versions can exist, for example.
// Official builds always end in an even number. (Since 0.10.2).
- private static final String VERSION = "1.18.8";
-// private static final String RELEASE_NAME = "Edgy Guinea Pig";
- private static final String RELEASE_NAME = "Envious Ferret";
+ private static final String VERSION = "1.18.9";
+ private static final String RELEASE_NAME = "Edgy Guinea Pig";
+// private static final String RELEASE_NAME = "Envious Ferret";
// Named version history:
// Angry Butterfly
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 660b9985..c6b51042 100755
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -242,8 +242,7 @@ public class HandleConstructor {
ASTNode source = sourceNode.get();
boolean staticConstrRequired = staticName != null && !staticName.equals("");
-
- if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return;
+
if (skipIfConstructorExists != SkipIfConstructorExists.NO) {
for (EclipseNode child : typeNode.down()) {
if (child.getKind() == Kind.ANNOTATION) {
@@ -273,12 +272,18 @@ public class HandleConstructor {
if (noArgs && noArgsConstructorExists(typeNode)) return;
- ConstructorDeclaration constr = createConstructor(
- staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fieldsToParam, forceDefaults,
- sourceNode, onConstructor);
- injectMethod(typeNode, constr);
+ if (!(skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS)) {
+ ConstructorDeclaration constr = createConstructor(
+ staticConstrRequired ? AccessLevel.PRIVATE : level, typeNode, fieldsToParam, forceDefaults,
+ sourceNode, onConstructor);
+ injectMethod(typeNode, constr);
+ }
+ generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, fieldsToParam, source);
+ }
+
+ private void generateStaticConstructor(boolean staticConstrRequired, EclipseNode typeNode, String staticName, AccessLevel level, Collection<EclipseNode> fields, ASTNode source) {
if (staticConstrRequired) {
- MethodDeclaration staticConstr = createStaticConstructor(level, staticName, typeNode, fieldsToParam, source);
+ MethodDeclaration staticConstr = createStaticConstructor(level, staticName, typeNode, fields, source);
injectMethod(typeNode, staticConstr);
}
}
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java
index 3c434d40..e0456782 100644
--- a/src/core/lombok/javac/handlers/HandleConstructor.java
+++ b/src/core/lombok/javac/handlers/HandleConstructor.java
@@ -55,8 +55,10 @@ import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
+import lombok.core.LombokNode;
import lombok.delombok.LombokOptionsFactory;
import lombok.javac.Javac;
+import lombok.javac.JavacAST;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -219,8 +221,8 @@ public class HandleConstructor {
private void generate(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, boolean allToDefault, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source, boolean noArgs) {
boolean staticConstrRequired = staticName != null && !staticName.equals("");
- if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return;
if (skipIfConstructorExists != SkipIfConstructorExists.NO) {
+
for (JavacNode child : typeNode.down()) {
if (child.getKind() == Kind.ANNOTATION) {
boolean skipGeneration = annotationTypeMatches(NoArgsConstructor.class, child) ||
@@ -230,7 +232,6 @@ public class HandleConstructor {
if (!skipGeneration && skipIfConstructorExists == SkipIfConstructorExists.YES) {
skipGeneration = annotationTypeMatches(Builder.class, child);
}
-
if (skipGeneration) {
if (staticConstrRequired) {
// @Data has asked us to generate a constructor, but we're going to skip this instruction, as an explicit 'make a constructor' annotation
@@ -246,8 +247,7 @@ public class HandleConstructor {
}
if (noArgs && noArgsConstructorExists(typeNode)) return;
-
- JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, allToDefault, source);
+
ListBuffer<Type> argTypes = new ListBuffer<Type>();
for (JavacNode fieldNode : fields) {
Type mirror = getMirrorForFieldType(fieldNode);
@@ -258,7 +258,15 @@ public class HandleConstructor {
argTypes.append(mirror);
}
List<Type> argTypes_ = argTypes == null ? null : argTypes.toList();
- injectMethod(typeNode, constr, argTypes_, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
+
+ if (!(skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS)) {
+ JCMethodDecl constr = createConstructor(staticConstrRequired ? AccessLevel.PRIVATE : level, onConstructor, typeNode, fields, allToDefault, source);
+ injectMethod(typeNode, constr, argTypes_, Javac.createVoidType(typeNode.getSymbolTable(), CTC_VOID));
+ }
+ generateStaticConstructor(staticConstrRequired, typeNode, staticName, level, allToDefault, fields, source, argTypes_);
+ }
+
+ private void generateStaticConstructor(boolean staticConstrRequired, JavacNode typeNode, String staticName, AccessLevel level, boolean allToDefault, List<JavacNode> fields, LombokNode<JavacAST, JavacNode, JCTree> source, List<Type> argTypes_) {
if (staticConstrRequired) {
ClassSymbol sym = ((JCClassDecl) typeNode.get()).sym;
Type returnType = sym == null ? null : sym.type;
diff --git a/test/transform/resource/after-delombok/ValueStaticConstructorOf.java b/test/transform/resource/after-delombok/ValueStaticConstructorOf.java
new file mode 100644
index 00000000..fe75f823
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValueStaticConstructorOf.java
@@ -0,0 +1,50 @@
+public final class ValueStaticConstructorOf {
+ private final String name;
+ private final Double price;
+ private ValueStaticConstructorOf(String name, Double price) {
+ this.name = name;
+ this.price = price;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static ValueStaticConstructorOf of(final String name, final Double price) {
+ return new ValueStaticConstructorOf(name, price);
+ }
+ @java.lang.SuppressWarnings("all")
+ public String getName() {
+ return this.name;
+ }
+ @java.lang.SuppressWarnings("all")
+ public Double getPrice() {
+ return this.price;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof ValueStaticConstructorOf)) return false;
+ final ValueStaticConstructorOf other = (ValueStaticConstructorOf) o;
+ final java.lang.Object this$name = this.getName();
+ final java.lang.Object other$name = other.getName();
+ if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
+ final java.lang.Object this$price = this.getPrice();
+ final java.lang.Object other$price = other.getPrice();
+ if (this$price == null ? other$price != null : !this$price.equals(other$price)) return false;
+ return true;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $name = this.getName();
+ result = result * PRIME + ($name == null ? 43 : $name.hashCode());
+ final java.lang.Object $price = this.getPrice();
+ result = result * PRIME + ($price == null ? 43 : $price.hashCode());
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "ValueStaticConstructorOf(name=" + this.getName() + ", price=" + this.getPrice() + ")";
+ }
+}
diff --git a/test/transform/resource/after-ecj/ValueStaticConstructorOf.java b/test/transform/resource/after-ecj/ValueStaticConstructorOf.java
new file mode 100644
index 00000000..6cf71ed4
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValueStaticConstructorOf.java
@@ -0,0 +1,47 @@
+import lombok.Value;
+public final @Value(staticConstructor = "of") class ValueStaticConstructorOf {
+ private final String name;
+ private final Double price;
+ private ValueStaticConstructorOf(String name, Double price) {
+ super();
+ this.name = name;
+ this.price = price;
+ }
+ public @java.lang.SuppressWarnings("all") String getName() {
+ return this.name;
+ }
+ public @java.lang.SuppressWarnings("all") Double getPrice() {
+ return this.price;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof ValueStaticConstructorOf)))
+ return false;
+ final ValueStaticConstructorOf other = (ValueStaticConstructorOf) o;
+ final java.lang.Object this$name = this.getName();
+ final java.lang.Object other$name = other.getName();
+ if (((this$name == null) ? (other$name != null) : (! this$name.equals(other$name))))
+ return false;
+ final java.lang.Object this$price = this.getPrice();
+ final java.lang.Object other$price = other.getPrice();
+ if (((this$price == null) ? (other$price != null) : (! this$price.equals(other$price))))
+ return false;
+ return true;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $name = this.getName();
+ result = ((result * PRIME) + (($name == null) ? 43 : $name.hashCode()));
+ final java.lang.Object $price = this.getPrice();
+ result = ((result * PRIME) + (($price == null) ? 43 : $price.hashCode()));
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (((("ValueStaticConstructorOf(name=" + this.getName()) + ", price=") + this.getPrice()) + ")");
+ }
+ public static @java.lang.SuppressWarnings("all") ValueStaticConstructorOf of(final String name, final Double price) {
+ return new ValueStaticConstructorOf(name, price);
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ValueStaticConstructorOf.java b/test/transform/resource/before/ValueStaticConstructorOf.java
new file mode 100644
index 00000000..ac857ffd
--- /dev/null
+++ b/test/transform/resource/before/ValueStaticConstructorOf.java
@@ -0,0 +1,12 @@
+import lombok.Value;
+@Value(staticConstructor = "of")
+public class ValueStaticConstructorOf {
+
+ String name;
+ Double price;
+
+ private ValueStaticConstructorOf(String name, Double price) {
+ this.name = name;
+ this.price = price;
+ }
+}