Skip to content

Commit

Permalink
Merge pull request #2136 from ataccama/customlog
Browse files Browse the repository at this point in the history
Fixes for CustomLog, AUTHORS entry, extended changlog
  • Loading branch information
rzwitserloot authored Jul 8, 2019
2 parents 7fe4896 + 2a98c4d commit 5ad6796
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Lombok contributors in alphabetical order:

Adam Juraszek <juriad@gmail.com>
Bulgakov Alexander <buls@yandex.ru>
Christian Nüssgens <christian@nuessgens.com>
Christian Sterzl <christian.sterzl@gmail.com>
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Lombok Changelog

### v1.18.9 "Edgy Guinea Pig"
* FEATURE: You can now configure a custom logger framework using the new `@CustomLog` annotation in combination with the `lombok.log.custom.declaration` configuration key. See the [log documentation](https://projectlombok.org/features/Log) for more information. [Pullrequest #2086](https://github.com/rzwitserloot/lombok/pull/2086) with thanks to Adam Juraszek.
* IMPROBABLE BREAKING CHANGE: Stricter validation of configuration keys dealing with identifiers and types (`lombok.log.fieldName`, `lombok.fieldNameConstants.innerTypeName`, `lombok.copyableAnnotations`).

### 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).
Expand Down
2 changes: 1 addition & 1 deletion src/core/lombok/core/configuration/TypeName.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static TypeName valueOf(String name) {
if (name == null || name.trim().isEmpty()) return null;

String trimmedName = name.trim();
for (String identifier : trimmedName.split(".")) {
for (String identifier : trimmedName.split("\\.")) {
if (!JavaIdentifiers.isValidJavaIdentifier(identifier)) throw new IllegalArgumentException("Invalid type name " + trimmedName + " (part " + identifier + ")");
}
return new TypeName(trimmedName);
Expand Down
2 changes: 1 addition & 1 deletion src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public static Annotation[] findCopyableAnnotations(EclipseNode node) {
TypeReference typeRef = annotation.type;
boolean match = false;
if (typeRef != null && typeRef.getTypeName() != null) {
for (TypeName cn : configuredCopyable) if (typeMatches(cn.toString(), node, typeRef)) {
for (TypeName cn : configuredCopyable) if (cn != null && typeMatches(cn.toString(), node, typeRef)) {
result.add(annotation);
match = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void createInnerTypeFieldNameConstants(EclipseNode typeNode, EclipseNode
TypeDeclaration parent = (TypeDeclaration) typeNode.get();
EclipseNode fieldsType = findInnerClass(typeNode, innerTypeName.getName());
boolean genConstr = false, genClinit = false;
char[] name = innerTypeName.getName().toCharArray();
char[] name = innerTypeName.getCharArray();
TypeDeclaration generatedInnerType = null;
if (fieldsType == null) {
generatedInnerType = new TypeDeclaration(parent.compilationResult);
Expand Down
5 changes: 5 additions & 0 deletions src/core/lombok/eclipse/handlers/HandleLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public static void processAnnotation(LoggingFramework framework, AnnotationValue
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
loggerTopic = null;
}
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
loggerTopic = "";
}

ClassLiteralAccess loggingType = selfType(owner, source);
Expand Down
5 changes: 5 additions & 0 deletions src/core/lombok/javac/handlers/HandleLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public static void processAnnotation(LoggingFramework framework, AnnotationValue
if (loggerTopic != null && loggerTopic.trim().isEmpty()) loggerTopic = null;
if (framework.getDeclaration().getParametersWithTopic() == null && loggerTopic != null) {
annotationNode.addError(framework.getAnnotationAsString() + " does not allow a topic.");
loggerTopic = null;
}
if (framework.getDeclaration().getParametersWithoutTopic() == null && loggerTopic == null) {
annotationNode.addError(framework.getAnnotationAsString() + " requires a topic.");
loggerTopic = "";
}

JCFieldAccess loggingType = selfType(typeNode);
Expand Down
4 changes: 2 additions & 2 deletions src/core/lombok/javac/handlers/JavacHandlerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ public static List<JCAnnotation> findCopyableAnnotations(JavacNode node) {
java.util.List<TypeName> configuredCopyable = node.getAst().readConfiguration(ConfigurationKeys.COPYABLE_ANNOTATIONS);

if (!annoName.isEmpty()) {
for (TypeName cn : configuredCopyable) if (typeMatches(cn.toString(), node, anno.annotationType)) return List.of(anno);
for (TypeName cn : configuredCopyable) if (cn != null && typeMatches(cn.toString(), node, anno.annotationType)) return List.of(anno);
for (String bn : BASE_COPYABLE_ANNOTATIONS) if (typeMatches(bn, node, anno.annotationType)) return List.of(anno);
}

Expand All @@ -1459,7 +1459,7 @@ public static List<JCAnnotation> findCopyableAnnotations(JavacNode node) {
if (child.getKind() == Kind.ANNOTATION) {
JCAnnotation annotation = (JCAnnotation) child.get();
boolean match = false;
for (TypeName cn : configuredCopyable) if (typeMatches(cn.toString(), node, annotation.annotationType)) {
for (TypeName cn : configuredCopyable) if (cn != null && typeMatches(cn.toString(), node, annotation.annotationType)) {
result.append(annotation);
match = true;
break;
Expand Down
2 changes: 1 addition & 1 deletion website/templates/features/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<@f.overview>
<p>
You put the variant of <code>@Log</code> on your class (whichever one applies to the logging system you use); you then have a static final <code>log</code> field, initialized as is the commonly proscribed way for the logging framework you use, which you can then use to write log statements.
You put the variant of <code>@Log</code> on your class (whichever one applies to the logging system you use); you then have a static final <code>log</code> field, initialized as is the commonly prescribed way for the logging framework you use, which you can then use to write log statements.
</p><p>
There are several choices available:<br />
<dl>
Expand Down

0 comments on commit 5ad6796

Please sign in to comment.