aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/AllArgsConstructor.java5
-rw-r--r--src/core/lombok/ConfigurationKeys.java10
-rw-r--r--src/core/lombok/Getter.java2
-rw-r--r--src/core/lombok/NoArgsConstructor.java2
-rw-r--r--src/core/lombok/RequiredArgsConstructor.java5
-rw-r--r--src/core/lombok/Setter.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleBuilder.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java40
-rw-r--r--src/core/lombok/experimental/Wither.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleConstructor.java43
-rw-r--r--test/transform/resource/after-delombok/Constructors.java13
-rw-r--r--test/transform/resource/after-delombok/ConstructorsConfiguration.java15
-rw-r--r--test/transform/resource/after-delombok/DataConfiguration.java38
-rw-r--r--test/transform/resource/after-ecj/Constructors.java7
-rw-r--r--test/transform/resource/after-ecj/ConstructorsConfiguration.java14
-rw-r--r--test/transform/resource/after-ecj/DataConfiguration.java34
-rw-r--r--test/transform/resource/before/Constructors.java3
-rw-r--r--test/transform/resource/before/ConstructorsConfiguration.java9
-rw-r--r--test/transform/resource/before/DataConfiguration.java5
-rw-r--r--usage_examples/experimental/onXExample_pre.jpage6
-rw-r--r--website/features/Constructor.html2
-rw-r--r--website/features/GetterSetter.html2
-rw-r--r--website/features/experimental/Wither.html2
-rw-r--r--website/features/experimental/onX.html4
26 files changed, 225 insertions, 54 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index d2fd6bcd..a3c9afd4 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -2,6 +2,7 @@ Lombok Changelog
----------------
### v1.12.7 "Edgy Guinea Pig"
+* CHANGE: suppressConstructorProperties should now be configured via lombok configuration.
* CHANGE: The `canEqual` method generated by `@EqualsAndHashCode`, `@Value` and `@Data` is now `protected` instead of `public`. [Issue #660](https://code.google.com/p/projectlombok/issues/detail?id=660)
* BUGFIX: Deadlocks would occasionally occur in eclipse when using lazy getters [Issue #590](https://code.google.com/p/projectlombok/issues/detail?id=590)
diff --git a/src/core/lombok/AllArgsConstructor.java b/src/core/lombok/AllArgsConstructor.java
index 068b7a68..cc494967 100644
--- a/src/core/lombok/AllArgsConstructor.java
+++ b/src/core/lombok/AllArgsConstructor.java
@@ -49,7 +49,7 @@ public @interface AllArgsConstructor {
String staticName() default "";
/**
- * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @AllArgsConstructor(onConstructor=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @AllArgsConstructor(onConstructor=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onConstructor() default {};
@@ -63,8 +63,7 @@ public @interface AllArgsConstructor {
* However, this annotation is new in 1.6 which means those compiling for 1.5 will need
* to set this value to true.
*
- * @deprecated Java 1.5 has already been end-of-lifed. As java 1.5 loses ground this
- * method will eventually be removed.
+ * @deprecated THIS FEATURE WILL BE REMOVED after March 31st 2015. Use configuration key {@link ConfigurationKeys#ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES} instead.
*/
@Deprecated
boolean suppressConstructorProperties() default false;
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java
index 639d2dda..dd339301 100644
--- a/src/core/lombok/ConfigurationKeys.java
+++ b/src/core/lombok/ConfigurationKeys.java
@@ -44,6 +44,16 @@ public class ConfigurationKeys {
public static final ConfigurationKey<FlagUsageType> ANY_CONSTRUCTOR_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.anyConstructor.flagUsage", "Emit a warning or error if any of the XxxArgsConstructor annotations are used.") {};
/**
+ * lombok configuration: {@code lombok.anyConstructor.suppressConstructorProperties} = {@code true} | {@code false}.
+ *
+ * If {@code false} or this configuration is omitted, all generated constructors with at least 1 argument get a {@code @ConstructorProperties}.
+ * To suppress the generation of it, set this configuration to {@code true}.
+ *
+ * NB: GWT projects, and probably android projects, should explicitly set this key to {@code true} for the entire project.
+ */
+ public static final ConfigurationKey<Boolean> ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES = new ConfigurationKey<Boolean>("lombok.anyConstructor.suppressConstructorProperties", "Suppress the generation of @ConstructorProperties for generated constructors (default: false).") {};
+
+ /**
* lombok configuration: {@code lombok.allArgsConstructor.flagUsage} = {@code WARNING} | {@code ERROR}.
*
* If set, <em>any</em> usage of {@code @AllArgsConstructor} results in a warning / error.
diff --git a/src/core/lombok/Getter.java b/src/core/lombok/Getter.java
index 57f5e40a..428f53ef 100644
--- a/src/core/lombok/Getter.java
+++ b/src/core/lombok/Getter.java
@@ -58,7 +58,7 @@ public @interface Getter {
lombok.AccessLevel value() default lombok.AccessLevel.PUBLIC;
/**
- * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Getter(onMethod=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Getter(onMethod=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onMethod() default @AnyAnnotation;
diff --git a/src/core/lombok/NoArgsConstructor.java b/src/core/lombok/NoArgsConstructor.java
index bbf2d9e6..cd3e5568 100644
--- a/src/core/lombok/NoArgsConstructor.java
+++ b/src/core/lombok/NoArgsConstructor.java
@@ -51,7 +51,7 @@ public @interface NoArgsConstructor {
String staticName() default "";
/**
- * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @NoArgsConstructor(onConstructor=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @NoArgsConstructor(onConstructor=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onConstructor() default {};
diff --git a/src/core/lombok/RequiredArgsConstructor.java b/src/core/lombok/RequiredArgsConstructor.java
index 31c4b81d..8bb57c1a 100644
--- a/src/core/lombok/RequiredArgsConstructor.java
+++ b/src/core/lombok/RequiredArgsConstructor.java
@@ -49,7 +49,7 @@ public @interface RequiredArgsConstructor {
String staticName() default "";
/**
- * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @RequiredArgsConstructor(onConstructor=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated constructor. The syntax for this feature is: {@code @RequiredArgsConstructor(onConstructor=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onConstructor() default {};
@@ -63,8 +63,7 @@ public @interface RequiredArgsConstructor {
* However, this annotation is new in 1.6 which means those compiling for 1.5 will need
* to set this value to true.
*
- * @deprecated Java 1.5 has already been end-of-lifed. As java 1.5 loses ground this
- * method will eventually be removed.
+ * @deprecated THIS FEATURE WILL BE REMOVED after March 31st 2015. Use configuration key {@link ConfigurationKeys#ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES} instead.
*/
@Deprecated
boolean suppressConstructorProperties() default false;
diff --git a/src/core/lombok/Setter.java b/src/core/lombok/Setter.java
index 22622520..5e07b802 100644
--- a/src/core/lombok/Setter.java
+++ b/src/core/lombok/Setter.java
@@ -59,12 +59,12 @@ public @interface Setter {
lombok.AccessLevel value() default lombok.AccessLevel.PUBLIC;
/**
- * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Setter(onMethod=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Setter(onMethod=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onMethod() default {};
/**
- * Any annotations listed here are put on the generated method's parameter. The syntax for this feature is: {@code @Setter(onParam=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated method's parameter. The syntax for this feature is: {@code @Setter(onParam=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onParam() default {};
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index 12b16934..59540d67 100644
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -120,7 +120,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
fields.add(fieldNode);
}
- new HandleConstructor().generateConstructor(tdParent, AccessLevel.PACKAGE, fields, null, SkipIfConstructorExists.I_AM_BUILDER, true, Collections.<Annotation>emptyList(), ast);
+ new HandleConstructor().generateConstructor(tdParent, AccessLevel.PACKAGE, fields, null, SkipIfConstructorExists.I_AM_BUILDER, null, Collections.<Annotation>emptyList(), ast);
returnType = namePlusTypeParamsToTypeReference(td.name, td.typeParameters, p);
typeParams = td.typeParameters;
@@ -209,7 +209,7 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
}
if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) {
- ConstructorDeclaration cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, builderType, Collections.<EclipseNode>emptyList(), true, ast, Collections.<Annotation>emptyList());
+ ConstructorDeclaration cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, builderType, Collections.<EclipseNode>emptyList(), null, ast, Collections.<Annotation>emptyList());
if (cd != null) injectMethod(builderType, cd);
}
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index 6b7df349..4e35ebb6 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -82,7 +82,7 @@ public class HandleConstructor {
List<Annotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@NoArgsConstructor(onConstructor=", annotationNode);
- new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, SkipIfConstructorExists.NO, false, onConstructor, ast);
+ new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, SkipIfConstructorExists.NO, null, onConstructor, ast);
}
}
@@ -95,10 +95,14 @@ public class HandleConstructor {
if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return;
RequiredArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
- String staticName = ann.staticName();
- @SuppressWarnings("deprecation")
- boolean suppressConstructorProperties = ann.suppressConstructorProperties();
if (level == AccessLevel.NONE) return;
+ String staticName = ann.staticName();
+ Boolean suppressConstructorProperties = null;
+ if (annotation.isExplicit("suppressConstructorProperties")) {
+ @SuppressWarnings("deprecation")
+ boolean suppress = ann.suppressConstructorProperties();
+ suppressConstructorProperties = suppress;
+ }
List<Annotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@RequiredArgsConstructor(onConstructor=", annotationNode);
@@ -143,10 +147,14 @@ public class HandleConstructor {
if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return;
AllArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
- String staticName = ann.staticName();
- @SuppressWarnings("deprecation")
- boolean suppressConstructorProperties = ann.suppressConstructorProperties();
if (level == AccessLevel.NONE) return;
+ String staticName = ann.staticName();
+ Boolean suppressConstructorProperties = null;
+ if (annotation.isExplicit("suppressConstructorProperties")) {
+ @SuppressWarnings("deprecation")
+ boolean suppress = ann.suppressConstructorProperties();
+ suppressConstructorProperties = suppress;
+ }
List<Annotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@AllArgsConstructor(onConstructor=", annotationNode);
@@ -169,18 +177,18 @@ public class HandleConstructor {
}
public void generateRequiredArgsConstructor(EclipseNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, List<Annotation> onConstructor, ASTNode source) {
- generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, skipIfConstructorExists, false, onConstructor, source);
+ generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, skipIfConstructorExists, null, onConstructor, source);
}
public void generateAllArgsConstructor(EclipseNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, List<Annotation> onConstructor, ASTNode source) {
- generateConstructor(typeNode, level, findAllFields(typeNode), staticName, skipIfConstructorExists, false, onConstructor, source);
+ generateConstructor(typeNode, level, findAllFields(typeNode), staticName, skipIfConstructorExists, null, onConstructor, source);
}
public enum SkipIfConstructorExists {
YES, NO, I_AM_BUILDER;
}
- public void generateConstructor(EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, String staticName, SkipIfConstructorExists skipIfConstructorExists, boolean suppressConstructorProperties, List<Annotation> onConstructor, ASTNode source) {
+ public void generateConstructor(EclipseNode typeNode, AccessLevel level, List<EclipseNode> fields, String staticName, SkipIfConstructorExists skipIfConstructorExists, Boolean suppressConstructorProperties, List<Annotation> onConstructor, ASTNode source) {
boolean staticConstrRequired = staticName != null && !staticName.equals("");
if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return;
@@ -251,7 +259,7 @@ public class HandleConstructor {
public static ConstructorDeclaration createConstructor(
AccessLevel level, EclipseNode type, Collection<EclipseNode> fields,
- boolean suppressConstructorProperties, ASTNode source, List<Annotation> onConstructor) {
+ Boolean suppressConstructorProperties, ASTNode source, List<Annotation> onConstructor) {
TypeDeclaration typeDeclaration = ((TypeDeclaration)type.get());
long p = (long)source.sourceStart << 32 | source.sourceEnd;
@@ -260,6 +268,14 @@ public class HandleConstructor {
if (isEnum) level = AccessLevel.PRIVATE;
+ if (suppressConstructorProperties == null) {
+ if (fields.isEmpty()) {
+ suppressConstructorProperties = false;
+ } else {
+ suppressConstructorProperties = Boolean.TRUE.equals(type.getAst().readConfiguration(ConfigurationKeys.ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES));
+ }
+ }
+
ConstructorDeclaration constructor = new ConstructorDeclaration(
((CompilationUnitDeclaration) type.top().get()).compilationResult);
@@ -309,7 +325,7 @@ public class HandleConstructor {
/* Generate annotations that must be put on the generated method, and attach them. */ {
Annotation[] constructorProperties = null;
- if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && !isLocalType(type)) {
+ if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && level != AccessLevel.PACKAGE && !isLocalType(type)) {
constructorProperties = createConstructorProperties(source, fields);
}
diff --git a/src/core/lombok/experimental/Wither.java b/src/core/lombok/experimental/Wither.java
index f667cb1f..fe113bb0 100644
--- a/src/core/lombok/experimental/Wither.java
+++ b/src/core/lombok/experimental/Wither.java
@@ -60,12 +60,12 @@ public @interface Wither {
AccessLevel value() default AccessLevel.PUBLIC;
/**
- * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Setter(onMethod=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated method. The syntax for this feature is: {@code @Setter(onMethod=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onMethod() default {};
/**
- * Any annotations listed here are put on the generated method's parameter. The syntax for this feature is: {@code @Setter(onParam=@_({@AnnotationsGoHere}))}
+ * Any annotations listed here are put on the generated method's parameter. The syntax for this feature is: {@code @Setter(onParam=@__({@AnnotationsGoHere}))}
*/
AnyAnnotation[] onParam() default {};
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index b382395e..bf3b39dc 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -114,7 +114,8 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
allFields.append(fieldNode);
}
- new HandleConstructor().generateConstructor(tdParent, AccessLevel.PACKAGE, List.<JCAnnotation>nil(), allFields.toList(), null, SkipIfConstructorExists.I_AM_BUILDER, true, annotationNode);
+
+ new HandleConstructor().generateConstructor(tdParent, AccessLevel.PACKAGE, List.<JCAnnotation>nil(), allFields.toList(), null, SkipIfConstructorExists.I_AM_BUILDER, null, annotationNode);
returnType = namePlusTypeParamsToTypeReference(tdParent.getTreeMaker(), td.name, td.typarams);
typeParams = td.typarams;
@@ -198,7 +199,7 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
}
if (constructorExists(builderType) == MemberExistsResult.NOT_EXISTS) {
- JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, List.<JCAnnotation>nil(), builderType, List.<JavacNode>nil(), true, ast);
+ JCMethodDecl cd = HandleConstructor.createConstructor(AccessLevel.PACKAGE, List.<JCAnnotation>nil(), builderType, List.<JavacNode>nil(), null, ast);
if (cd != null) injectMethod(builderType, cd);
}
diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java
index adfa253f..0618706e 100644
--- a/src/core/lombok/javac/handlers/HandleConstructor.java
+++ b/src/core/lombok/javac/handlers/HandleConstructor.java
@@ -69,10 +69,10 @@ public class HandleConstructor {
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@NoArgsConstructor(onConstructor=", annotationNode);
NoArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
- String staticName = ann.staticName();
if (level == AccessLevel.NONE) return;
+ String staticName = ann.staticName();
List<JavacNode> fields = List.nil();
- new HandleConstructor().generateConstructor(typeNode, level, onConstructor, fields, staticName, SkipIfConstructorExists.NO, false, annotationNode);
+ new HandleConstructor().generateConstructor(typeNode, level, onConstructor, fields, staticName, SkipIfConstructorExists.NO, null, annotationNode);
}
}
@@ -88,10 +88,15 @@ public class HandleConstructor {
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@RequiredArgsConstructor(onConstructor=", annotationNode);
RequiredArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
- String staticName = ann.staticName();
- @SuppressWarnings("deprecation")
- boolean suppressConstructorProperties = ann.suppressConstructorProperties();
if (level == AccessLevel.NONE) return;
+ String staticName = ann.staticName();
+ Boolean suppressConstructorProperties = null;
+ if (annotation.isExplicit("suppressConstructorProperties")) {
+ @SuppressWarnings("deprecation")
+ boolean suppress = ann.suppressConstructorProperties();
+ suppressConstructorProperties = suppress;
+ }
+
new HandleConstructor().generateConstructor(typeNode, level, onConstructor, findRequiredFields(typeNode), staticName, SkipIfConstructorExists.NO, suppressConstructorProperties, annotationNode);
}
}
@@ -125,10 +130,14 @@ public class HandleConstructor {
List<JCAnnotation> onConstructor = unboxAndRemoveAnnotationParameter(ast, "onConstructor", "@AllArgsConstructor(onConstructor=", annotationNode);
AllArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
- String staticName = ann.staticName();
- @SuppressWarnings("deprecation")
- boolean suppressConstructorProperties = ann.suppressConstructorProperties();
if (level == AccessLevel.NONE) return;
+ String staticName = ann.staticName();
+ Boolean suppressConstructorProperties = null;
+ if (annotation.isExplicit("suppressConstructorProperties")) {
+ @SuppressWarnings("deprecation")
+ boolean suppress = ann.suppressConstructorProperties();
+ suppressConstructorProperties = suppress;
+ }
new HandleConstructor().generateConstructor(typeNode, level, onConstructor, findAllFields(typeNode), staticName, SkipIfConstructorExists.NO, suppressConstructorProperties, annotationNode);
}
}
@@ -165,7 +174,7 @@ public class HandleConstructor {
}
public void generateRequiredArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) {
- generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findRequiredFields(typeNode), staticName, skipIfConstructorExists, false, source);
+ generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findRequiredFields(typeNode), staticName, skipIfConstructorExists, null, source);
}
public enum SkipIfConstructorExists {
@@ -173,10 +182,10 @@ public class HandleConstructor {
}
public void generateAllArgsConstructor(JavacNode typeNode, AccessLevel level, String staticName, SkipIfConstructorExists skipIfConstructorExists, JavacNode source) {
- generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findAllFields(typeNode), staticName, skipIfConstructorExists, false, source);
+ generateConstructor(typeNode, level, List.<JCAnnotation>nil(), findAllFields(typeNode), staticName, skipIfConstructorExists, null, source);
}
- public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, String staticName, SkipIfConstructorExists skipIfConstructorExists, boolean suppressConstructorProperties, JavacNode source) {
+ public void generateConstructor(JavacNode typeNode, AccessLevel level, List<JCAnnotation> onConstructor, List<JavacNode> fields, String staticName, SkipIfConstructorExists skipIfConstructorExists, Boolean suppressConstructorProperties, JavacNode source) {
boolean staticConstrRequired = staticName != null && !staticName.equals("");
if (skipIfConstructorExists != SkipIfConstructorExists.NO && constructorExists(typeNode) != MemberExistsResult.NOT_EXISTS) return;
@@ -227,12 +236,20 @@ public class HandleConstructor {
mods.annotations = mods.annotations.append(annotation);
}
- public static JCMethodDecl createConstructor(AccessLevel level, List<JCAnnotation> onConstructor, JavacNode typeNode, List<JavacNode> fields, boolean suppressConstructorProperties, JCTree source) {
+ public static JCMethodDecl createConstructor(AccessLevel level, List<JCAnnotation> onConstructor, JavacNode typeNode, List<JavacNode> fields, Boolean suppressConstructorProperties, JCTree source) {
JavacTreeMaker maker = typeNode.getTreeMaker();
boolean isEnum = (((JCClassDecl) typeNode.get()).mods.flags & Flags.ENUM) != 0;
if (isEnum) level = AccessLevel.PRIVATE;
+ if (suppressConstructorProperties == null) {
+ if (fields.isEmpty()) {
+ suppressConstructorProperties = false;
+ } else {
+ suppressConstructorProperties = Boolean.TRUE.equals(typeNode.getAst().readConfiguration(ConfigurationKeys.ANY_CONSTRUCTOR_SUPPRESS_CONSTRUCTOR_PROPERTIES));
+ }
+ }
+
ListBuffer<JCStatement> nullChecks = new ListBuffer<JCStatement>();
ListBuffer<JCStatement> assigns = new ListBuffer<JCStatement>();
ListBuffer<JCVariableDecl> params = new ListBuffer<JCVariableDecl>();
@@ -257,7 +274,7 @@ public class HandleConstructor {
}
JCModifiers mods = maker.Modifiers(toJavacModifier(level), List.<JCAnnotation>nil());
- if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && !isLocalType(typeNode) && LombokOptionsFactory.getDelombokOptions(typeNode.getContext()).getFormatPreferences().generateConstructorProperties()) {
+ if (!suppressConstructorProperties && level != AccessLevel.PRIVATE && level != AccessLevel.PACKAGE && !isLocalType(typeNode) && LombokOptionsFactory.getDelombokOptions(typeNode.getContext()).getFormatPreferences().generateConstructorProperties()) {
addConstructorProperties(mods, typeNode, fields);
}
if (onConstructor != null) mods.annotations = mods.annotations.appendList(copyAnnotations(onConstructor));
diff --git a/test/transform/resource/after-delombok/Constructors.java b/test/transform/resource/after-delombok/Constructors.java
index 12aa75ab..4ffdc62b 100644
--- a/test/transform/resource/after-delombok/Constructors.java
+++ b/test/transform/resource/after-delombok/Constructors.java
@@ -58,12 +58,10 @@ class NoArgsConstructor1 {
class RequiredArgsConstructorStaticNameGenerics<T extends Number> {
final T x;
String name;
-
@java.lang.SuppressWarnings("all")
private RequiredArgsConstructorStaticNameGenerics(final T x) {
this.x = x;
}
-
@java.lang.SuppressWarnings("all")
public static <T extends Number> RequiredArgsConstructorStaticNameGenerics<T> of(final T x) {
return new RequiredArgsConstructorStaticNameGenerics<T>(x);
@@ -72,14 +70,19 @@ class RequiredArgsConstructorStaticNameGenerics<T extends Number> {
class RequiredArgsConstructorStaticNameGenerics2<T extends Number> {
final Class<T> x;
String name;
-
@java.lang.SuppressWarnings("all")
private RequiredArgsConstructorStaticNameGenerics2(final Class<T> x) {
this.x = x;
}
-
@java.lang.SuppressWarnings("all")
public static <T extends Number> RequiredArgsConstructorStaticNameGenerics2<T> of(final Class<T> x) {
return new RequiredArgsConstructorStaticNameGenerics2<T>(x);
}
-} \ No newline at end of file
+}
+class AllArgsConstructorPackageAccess {
+ final String x;
+ @java.lang.SuppressWarnings("all")
+ AllArgsConstructorPackageAccess(final String x) {
+ this.x = x;
+ }
+}
diff --git a/test/transform/resource/after-delombok/ConstructorsConfiguration.java b/test/transform/resource/after-delombok/ConstructorsConfiguration.java
new file mode 100644
index 00000000..5bec3ae3
--- /dev/null
+++ b/test/transform/resource/after-delombok/ConstructorsConfiguration.java
@@ -0,0 +1,15 @@
+class ConstructorsConfiguration {
+ int x;
+ @java.lang.SuppressWarnings("all")
+ public ConstructorsConfiguration(final int x) {
+ this.x = x;
+ }
+}
+class ConstructorsConfigurationExplicit {
+ int x;
+ @java.beans.ConstructorProperties({"x"})
+ @java.lang.SuppressWarnings("all")
+ public ConstructorsConfigurationExplicit(final int x) {
+ this.x = x;
+ }
+}
diff --git a/test/transform/resource/after-delombok/DataConfiguration.java b/test/transform/resource/after-delombok/DataConfiguration.java
new file mode 100644
index 00000000..230083ec
--- /dev/null
+++ b/test/transform/resource/after-delombok/DataConfiguration.java
@@ -0,0 +1,38 @@
+class DataConfiguration {
+ final int x;
+ @java.lang.SuppressWarnings("all")
+ public DataConfiguration(final int x) {
+ this.x = x;
+ }
+ @java.lang.SuppressWarnings("all")
+ public int getX() {
+ return this.x;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof DataConfiguration)) return false;
+ final DataConfiguration other = (DataConfiguration)o;
+ if (!other.canEqual((java.lang.Object)this)) return false;
+ if (this.getX() != other.getX()) return false;
+ return true;
+ }
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof DataConfiguration;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = result * PRIME + this.getX();
+ return result;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "DataConfiguration(x=" + this.getX() + ")";
+ }
+}
diff --git a/test/transform/resource/after-ecj/Constructors.java b/test/transform/resource/after-ecj/Constructors.java
index 540c2407..a4597ce6 100644
--- a/test/transform/resource/after-ecj/Constructors.java
+++ b/test/transform/resource/after-ecj/Constructors.java
@@ -70,4 +70,11 @@
public static @java.lang.SuppressWarnings("all") <T extends Number>RequiredArgsConstructorStaticNameGenerics2<T> of(final Class<T> x) {
return new RequiredArgsConstructorStaticNameGenerics2<T>(x);
}
+}
+@lombok.AllArgsConstructor(access = lombok.AccessLevel.PACKAGE) class AllArgsConstructorPackageAccess {
+ final String x;
+ @java.lang.SuppressWarnings("all") AllArgsConstructorPackageAccess(final String x) {
+ super();
+ this.x = x;
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ConstructorsConfiguration.java b/test/transform/resource/after-ecj/ConstructorsConfiguration.java
new file mode 100644
index 00000000..b55d3e03
--- /dev/null
+++ b/test/transform/resource/after-ecj/ConstructorsConfiguration.java
@@ -0,0 +1,14 @@
+@lombok.AllArgsConstructor class ConstructorsConfiguration {
+ int x;
+ public @java.lang.SuppressWarnings("all") ConstructorsConfiguration(final int x) {
+ super();
+ this.x = x;
+ }
+}
+@lombok.AllArgsConstructor(suppressConstructorProperties = false) class ConstructorsConfigurationExplicit {
+ int x;
+ public @java.beans.ConstructorProperties({"x"}) @java.lang.SuppressWarnings("all") ConstructorsConfigurationExplicit(final int x) {
+ super();
+ this.x = x;
+ }
+}
diff --git a/test/transform/resource/after-ecj/DataConfiguration.java b/test/transform/resource/after-ecj/DataConfiguration.java
new file mode 100644
index 00000000..f2733a88
--- /dev/null
+++ b/test/transform/resource/after-ecj/DataConfiguration.java
@@ -0,0 +1,34 @@
+@lombok.Data class DataConfiguration {
+ final int x;
+ public @java.lang.SuppressWarnings("all") int getX() {
+ return this.x;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof DataConfiguration)))
+ return false;
+ final @java.lang.SuppressWarnings("all") DataConfiguration other = (DataConfiguration) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ if ((this.getX() != other.getX()))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof DataConfiguration);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ result = ((result * PRIME) + this.getX());
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("DataConfiguration(x=" + this.getX()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") DataConfiguration(final int x) {
+ super();
+ this.x = x;
+ }
+}
diff --git a/test/transform/resource/before/Constructors.java b/test/transform/resource/before/Constructors.java
index 45b3a199..c80acf2b 100644
--- a/test/transform/resource/before/Constructors.java
+++ b/test/transform/resource/before/Constructors.java
@@ -30,3 +30,6 @@
final Class<T> x;
String name;
}
+@lombok.AllArgsConstructor(access=lombok.AccessLevel.PACKAGE) class AllArgsConstructorPackageAccess {
+ final String x;
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ConstructorsConfiguration.java b/test/transform/resource/before/ConstructorsConfiguration.java
new file mode 100644
index 00000000..8fae10fc
--- /dev/null
+++ b/test/transform/resource/before/ConstructorsConfiguration.java
@@ -0,0 +1,9 @@
+//CONF: lombok.anyConstructor.suppressConstructorProperties = true
+@lombok.AllArgsConstructor
+class ConstructorsConfiguration {
+ int x;
+}
+@lombok.AllArgsConstructor(suppressConstructorProperties=false)
+class ConstructorsConfigurationExplicit {
+ int x;
+}
diff --git a/test/transform/resource/before/DataConfiguration.java b/test/transform/resource/before/DataConfiguration.java
new file mode 100644
index 00000000..660d6d18
--- /dev/null
+++ b/test/transform/resource/before/DataConfiguration.java
@@ -0,0 +1,5 @@
+//CONF: lombok.anyConstructor.suppressConstructorProperties = true
+@lombok.Data
+class DataConfiguration {
+ final int x;
+}
diff --git a/usage_examples/experimental/onXExample_pre.jpage b/usage_examples/experimental/onXExample_pre.jpage
index fa03e2cd..f8fcb435 100644
--- a/usage_examples/experimental/onXExample_pre.jpage
+++ b/usage_examples/experimental/onXExample_pre.jpage
@@ -7,9 +7,9 @@ import javax.persistence.Id;
import javax.persistence.Column;
import javax.validation.constraints.Max;
-@AllArgsConstructor(onConstructor=@_(@Inject))
+@AllArgsConstructor(onConstructor=@__(@Inject))
public class OnXExample {
- @Getter(onMethod=@_({@Id, @Column(name="unique-id")}))
- @Setter(onParam=@_(@Max(10000)))
+ @Getter(onMethod=@__({@Id, @Column(name="unique-id")}))
+ @Setter(onParam=@__(@Max(10000)))
private long unid;
}
diff --git a/website/features/Constructor.html b/website/features/Constructor.html
index 272df06e..c7e40dfb 100644
--- a/website/features/Constructor.html
+++ b/website/features/Constructor.html
@@ -35,7 +35,7 @@
Such a static factory method will infer generics, unlike a normal constructor. This means your API users get write <code>MapEntry.of("foo", 5)</code> instead of the much longer
<code>new MapEntry&lt;String, Integer&gt;("foo", 5)</code>.
</p><p>
- To put annotations on the generated constructor, you can use <code>onConstructor=@_({@AnnotationsHere})</code>, but be careful; this is an experimental feature. For more details see the documentation on the <a href="experimental/onX.html">onX</a> feature.
+ To put annotations on the generated constructor, you can use <code>onConstructor=@__({@AnnotationsHere})</code>, but be careful; this is an experimental feature. For more details see the documentation on the <a href="experimental/onX.html">onX</a> feature.
</p><p>
Static fields are skipped by these annotations. Also, a <code>@java.beans.ConstructorProperties</code> annotation is added for all constructors with at least 1 argument,
which allows bean editor tools to call the generated constructors. <code>@ConstructorProperties</code> is now in Java 1.6, which means that if your code is intended for
diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html
index 7e2ff226..2e39e1ad 100644
--- a/website/features/GetterSetter.html
+++ b/website/features/GetterSetter.html
@@ -29,7 +29,7 @@
You can always manually disable getter/setter generation for any field by using the special <code>AccessLevel.NONE</code> access level. This lets you override the
behaviour of a <code>@Getter</code>, <code>@Setter</code> or <code>@Data</code> annotation on a class.
</p><p>
- To put annotations on the generated method, you can use <code>onMethod=@_({@AnnotationsHere})</code>; to put annotations on the only parameter of a generated setter method, you can use <code>onParam=@_({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="experimental/onX.html">onX</a> feature.
+ To put annotations on the generated method, you can use <code>onMethod=@__({@AnnotationsHere})</code>; to put annotations on the only parameter of a generated setter method, you can use <code>onParam=@__({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="experimental/onX.html">onX</a> feature.
</p><p>
<em>NEW in lombok v1.12.0:</em> javadoc on the field will now be copied to generated getters and setters. Normally, all text is copied, and <code>@return</code> is <em>moved</em> to the getter, whilst <code>@param</code> lines are <em>moved</em> to the setter. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for each getter/setter. To do that, you create a 'section' named <code>GETTER</code> and/or <code>SETTER</code>. A section is a line in your javadoc containing 2 or more dashes, then the text 'GETTER' or 'SETTER', followed by 2 or more dashes, and nothing else on the line. If you use sections, <code>@return</code> and <code>@param</code> stripping for that section is no longer done (move the <code>@return</code> or <code>@param</code> line into the section).
</p>
diff --git a/website/features/experimental/Wither.html b/website/features/experimental/Wither.html
index b334cd7c..46d3b08b 100644
--- a/website/features/experimental/Wither.html
+++ b/website/features/experimental/Wither.html
@@ -45,7 +45,7 @@
<code>@Wither(level = AccessLevel.PROTECTED)</code>. Also like <a href="../GetterSetter.html"><code>@Setter</code></a>, you can also put a <code>@Wither</code> annotation on a type, which means
a 'wither' is generated for each field (even non-final fields).
</p><p>
- To put annotations on the generated method, you can use <code>onMethod=@_({@AnnotationsHere})</code>; to put annotations on the only parameter of a generated wither method, you can use <code>onParam=@_({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="onX.html">onX</a> feature.
+ To put annotations on the generated method, you can use <code>onMethod=@__({@AnnotationsHere})</code>; to put annotations on the only parameter of a generated wither method, you can use <code>onParam=@__({@AnnotationsHere})</code>. Be careful though! This is an experimental feature. For more details see the documentation on the <a href="onX.html">onX</a> feature.
</p><p>
<em>NEW in lombok v1.12.0:</em> javadoc on the field will now be copied to generated withers. Normally, all text is copied, and <code>@param</code> is <em>moved</em> to the wither, whilst <code>@return</code> lines are stripped from the wither's javadoc. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for the wither's javadoc. To do that, you create a 'section' named <code>WITHER</code>. A section is a line in your javadoc containing 2 or more dashes, then the text 'WITHER', followed by 2 or more dashes, and nothing else on the line. If you use sections, <code>@return</code> and <code>@param</code> stripping / copying for that section is no longer done (move the <code>@param</code> line into the section).
</p>
diff --git a/website/features/experimental/onX.html b/website/features/experimental/onX.html
index 66b0164f..530d98a4 100644
--- a/website/features/experimental/onX.html
+++ b/website/features/experimental/onX.html
@@ -42,7 +42,7 @@
</p><p>
<code>@Setter</code> and <code>@Wither</code> support <code>onParam</code> in addition to <code>onMethod</code>; annotations listed will be put on the only parameter that the generated method has.
</p><p>
- The syntax is a little strange; to use any of the 3 <code>onX</code> features, you must wrap the annotations to be applied to the constructor / method / parameter in <code>@_(@AnnotationGoesHere)</code>. To apply multiple annotations, use <code>@_({@Annotation1, @Annotation2})</code>. The annotations can themselves obviously have parameters as well.
+ The syntax is a little strange; to use any of the 3 <code>onX</code> features, you must wrap the annotations to be applied to the constructor / method / parameter in <code>@__(@AnnotationGoesHere)</code>. To apply multiple annotations, use <code>@__({@Annotation1, @Annotation2})</code>. The annotations can themselves obviously have parameters as well.
</p>
</div>
<div class="snippets">
@@ -60,7 +60,7 @@
<div class="overview">
<h3>Small print</h3><div class="smallprint">
<p>
- The reason of the weird syntax is to make this feature work in javac 7 compilers; the <code>@_</code> type is an annotation reference to the annotation type <code>_</code> (underscore) which doesn't actually exist; this makes javac 7 delay aborting the compilation process due to an error because it is possible an annotation processor will later create the <code>_</code> type. Instead, lombok applies the annotations and removes the references so that the error will never actually occur. The point is: The <code>_</code> type <em>must not exist</em>, otherwise the feature does not work. In the rare case that the <code>_</code> type does exist (and is imported or in the package), you can simply add more underscores. Technically any non-existent type would work, but to maintain consistency and readability and catch erroneous use, lombok considers it an error if the 'wrapper' annotation is anything but a series of underscores.
+ The reason of the weird syntax is to make this feature work in javac 7 compilers; the <code>@__</code> type is an annotation reference to the annotation type <code>_</code> (underscore) which doesn't actually exist; this makes javac 7 delay aborting the compilation process due to an error because it is possible an annotation processor will later create the <code>_</code> type. Instead, lombok applies the annotations and removes the references so that the error will never actually occur. The point is: The <code>_</code> type <em>must not exist</em>, otherwise the feature does not work. In the rare case that the <code>_</code> type does exist (and is imported or in the package), you can simply add more underscores. Technically any non-existent type would work, but to maintain consistency and readability and catch erroneous use, lombok considers it an error if the 'wrapper' annotation is anything but a series of underscores.
</p><p>
To reiterate: This feature can disappear at any time; if you use this feature, be prepared to adjust your code when we find a nicer way of implementing this feature, or, if a future version of javac forces us to remove this feature entirely with no alternative.
</p><p>