From 05b8501071b7a7d1a31713c607785b94119767d0 Mon Sep 17 00:00:00 2001 From: Jan Ouwens Date: Sun, 11 Aug 2013 21:13:16 +0200 Subject: Oops: didn't realise the text appeared in multiple places. --- .../EqualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- .../EqualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages index 9a0b29f3..0b72b14f 100644 --- a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4:1 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15:1 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4:1 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). +15:1 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages index cf6ebea2..227ca9a6 100644 --- a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4:57 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15:194 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4:57 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). +15:194 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). -- cgit From 95cf815285ee736d3bc8119773139cb4fe0c1fb4 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 12 Aug 2013 22:51:13 +0200 Subject: replaced double underscore as new standard way of writing the dummy annotation for onX instead of single underscore, which emits warnings on javac8+. Also made dollars and Xes legal in addition to underscores, in case double underscore disappears later too. --- .../eclipse/handlers/EclipseHandlerUtil.java | 36 +++++++++++----------- .../lombok/javac/handlers/JavacHandlerUtil.java | 12 ++++---- test/transform/resource/before/Constructors.java | 2 +- test/transform/resource/before/GetterOnMethod.java | 4 +-- .../resource/before/GetterOnMethodErrors.java | 2 +- .../resource/before/GetterOnMethodErrors2.java | 14 ++++----- .../resource/before/SetterOnMethodOnParam.java | 4 +-- .../GetterOnMethodErrors2.java.messages | 8 ++--- .../GetterOnMethodErrors2.java.messages | 8 ++--- 9 files changed, 45 insertions(+), 45 deletions(-) (limited to 'test') diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 9bd634f7..d74b8981 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1562,9 +1562,9 @@ public class EclipseHandlerUtil { intLiteralFactoryMethod = intLiteralFactoryMethod_; } - private static boolean isAllUnderscores(char[] in) { + private static boolean isAllValidOnXCharacters(char[] in) { if (in == null || in.length == 0) return false; - for (char c : in) if (c != '_') return false; + for (char c : in) if (c != '_' && c != 'X' && c != 'x' && c != '$') return false; return true; } @@ -1597,31 +1597,31 @@ public class EclipseHandlerUtil { if (i > 0) System.arraycopy(pairs, 0, newPairs, 0, i); if (i < pairs.length - 1) System.arraycopy(pairs, i + 1, newPairs, i, pairs.length - i - 1); normalAnnotation.memberValuePairs = newPairs; - // We have now removed the annotation parameter and stored '@_({... annotations ...})', + // We have now removed the annotation parameter and stored '@__({... annotations ...})', // which we must now unbox. if (!(value instanceof Annotation)) { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); return Collections.emptyList(); } - Annotation atUnderscore = (Annotation) value; - if (!(atUnderscore.type instanceof SingleTypeReference) || - !isAllUnderscores(((SingleTypeReference) atUnderscore.type).token)) { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + Annotation atDummyIdentifier = (Annotation) value; + if (!(atDummyIdentifier.type instanceof SingleTypeReference) || + !isAllValidOnXCharacters(((SingleTypeReference) atDummyIdentifier.type).token)) { + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); return Collections.emptyList(); } - if (atUnderscore instanceof MarkerAnnotation) { - // It's @getter(onMethod=@_). This is weird, but fine. + if (atDummyIdentifier instanceof MarkerAnnotation) { + // It's @Getter(onMethod=@__). This is weird, but fine. return Collections.emptyList(); } Expression content = null; - if (atUnderscore instanceof NormalAnnotation) { - MemberValuePair[] mvps = ((NormalAnnotation) atUnderscore).memberValuePairs; + if (atDummyIdentifier instanceof NormalAnnotation) { + MemberValuePair[] mvps = ((NormalAnnotation) atDummyIdentifier).memberValuePairs; if (mvps == null || mvps.length == 0) { - // It's @getter(onMethod=@_()). This is weird, but fine. + // It's @Getter(onMethod=@__()). This is weird, but fine. return Collections.emptyList(); } if (mvps.length == 1 && Arrays.equals("value".toCharArray(), mvps[0].name)) { @@ -1629,12 +1629,12 @@ public class EclipseHandlerUtil { } } - if (atUnderscore instanceof SingleMemberAnnotation) { - content = ((SingleMemberAnnotation) atUnderscore).memberValue; + if (atDummyIdentifier instanceof SingleMemberAnnotation) { + content = ((SingleMemberAnnotation) atDummyIdentifier).memberValue; } if (content == null) { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); return Collections.emptyList(); } @@ -1646,13 +1646,13 @@ public class EclipseHandlerUtil { if (expressions != null) for (Expression ex : expressions) { if (ex instanceof Annotation) result.add((Annotation) ex); else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); return Collections.emptyList(); } } return result; } else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); return Collections.emptyList(); } } diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 65997f9a..d518c4df 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -1009,9 +1009,9 @@ public class JavacHandlerUtil { if (valueOfParam instanceof JCAnnotation) { String dummyAnnotationName = ((JCAnnotation) valueOfParam).annotationType.toString(); - dummyAnnotationName = dummyAnnotationName.replace("_", ""); + dummyAnnotationName = dummyAnnotationName.replace("_", "").replace("$", "").replace("x", "").replace("X", ""); if (dummyAnnotationName.length() > 0) { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); continue outer; } for (JCExpression expr : ((JCAnnotation) valueOfParam).args) { @@ -1020,7 +1020,7 @@ public class JavacHandlerUtil { if ("value".equals(id.name.toString())) { expr = ((JCAssign) expr).rhs; } else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); continue outer; } } @@ -1032,12 +1032,12 @@ public class JavacHandlerUtil { if (expr2 instanceof JCAnnotation) { result.append((JCAnnotation) expr2); } else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); continue outer; } } } else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); continue outer; } } @@ -1045,7 +1045,7 @@ public class JavacHandlerUtil { if (valueOfParam instanceof JCNewArray && ((JCNewArray) valueOfParam).elems.isEmpty()) { // Then we just remove it and move on (it's onMethod={} for example). } else { - errorNode.addError("The correct format is " + errorName + "@_({@SomeAnnotation, @SomeOtherAnnotation}))"); + errorNode.addError("The correct format is " + errorName + "@__({@SomeAnnotation, @SomeOtherAnnotation}))"); } } } diff --git a/test/transform/resource/before/Constructors.java b/test/transform/resource/before/Constructors.java index 0ab7b7f0..45b3a199 100644 --- a/test/transform/resource/before/Constructors.java +++ b/test/transform/resource/before/Constructors.java @@ -10,7 +10,7 @@ final int x; String name; } -@lombok.RequiredArgsConstructor(onConstructor=@_(@Deprecated)) class RequiredArgsConstructorWithAnnotations { +@lombok.RequiredArgsConstructor(onConstructor=@__(@Deprecated)) class RequiredArgsConstructorWithAnnotations { final int x; String name; } diff --git a/test/transform/resource/before/GetterOnMethod.java b/test/transform/resource/before/GetterOnMethod.java index 558f3f64..3e56a66e 100644 --- a/test/transform/resource/before/GetterOnMethod.java +++ b/test/transform/resource/before/GetterOnMethod.java @@ -1,6 +1,6 @@ class GetterOnMethod { - @lombok.Getter(onMethod=@_(@Deprecated)) int i; - @lombok.Getter(onMethod=@_({@java.lang.Deprecated, @Test})) int j, k; + @lombok.Getter(onMethod=@__(@Deprecated)) int i; + @lombok.Getter(onMethod=@__({@java.lang.Deprecated, @Test})) int j, k; public @interface Test { } diff --git a/test/transform/resource/before/GetterOnMethodErrors.java b/test/transform/resource/before/GetterOnMethodErrors.java index ae5d5b54..ec4704f0 100644 --- a/test/transform/resource/before/GetterOnMethodErrors.java +++ b/test/transform/resource/before/GetterOnMethodErrors.java @@ -1,6 +1,6 @@ class PlaceFillerToMakeSurePositionIsRelevant { } -@lombok.Getter(onMethod=@_(@Deprecated)) +@lombok.Getter(onMethod=@__(@Deprecated)) class GetterOnMethodErrors { private int test; } diff --git a/test/transform/resource/before/GetterOnMethodErrors2.java b/test/transform/resource/before/GetterOnMethodErrors2.java index 423183b9..2fd98c83 100644 --- a/test/transform/resource/before/GetterOnMethodErrors2.java +++ b/test/transform/resource/before/GetterOnMethodErrors2.java @@ -1,12 +1,12 @@ class GetterOnMethodErrors2 { @lombok.Getter(onMethod=@_A_(@Deprecated)) private int bad1; - @lombok.Getter(onMethod=@_(5)) private int bad2; - @lombok.Getter(onMethod=@_({@Deprecated, 5})) private int bad3; - @lombok.Getter(onMethod=@_(bar=@Deprecated)) private int bad4; - @lombok.Getter(onMethod=@_) private int good1; - @lombok.Getter(onMethod=@_()) private int good2; - @lombok.Getter(onMethod=@_(value=@Deprecated)) private int good3; - @lombok.Getter(onMethod=@_(value={@Deprecated, @Test})) private int good4; + @lombok.Getter(onMethod=@__(5)) private int bad2; + @lombok.Getter(onMethod=@__({@Deprecated, 5})) private int bad3; + @lombok.Getter(onMethod=@$(bar=@Deprecated)) private int bad4; + @lombok.Getter(onMethod=@__) private int good1; + @lombok.Getter(onMethod=@X()) private int good2; + @lombok.Getter(onMethod=@__(value=@Deprecated)) private int good3; + @lombok.Getter(onMethod=@xXx$$(value={@Deprecated, @Test})) private int good4; public @interface Test { } } diff --git a/test/transform/resource/before/SetterOnMethodOnParam.java b/test/transform/resource/before/SetterOnMethodOnParam.java index 70f3dc8c..4e042cf4 100644 --- a/test/transform/resource/before/SetterOnMethodOnParam.java +++ b/test/transform/resource/before/SetterOnMethodOnParam.java @@ -1,6 +1,6 @@ class SetterOnMethodOnParam { - @lombok.Setter(onMethod=@_(@Deprecated)) int i; - @lombok.Setter(onMethod=@_({@java.lang.Deprecated, @Test}), onParam=@_(@Test)) int j, k; + @lombok.Setter(onMethod=@__(@Deprecated)) int i; + @lombok.Setter(onMethod=@__({@java.lang.Deprecated, @Test}), onParam=@__(@Test)) int j, k; public @interface Test { } diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages index ead040a5..b5bad45b 100644 --- a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -3:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -4:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -5:9 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +2:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +3:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +4:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +5:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages index 6b949f41..f87b9f13 100644 --- a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2:31 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -3:93 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -4:143 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -5:208 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +2:31 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +3:93 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +4:144 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +5:210 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -- cgit From b93318da303b36957f3774015090121af778665f Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 14 Aug 2013 07:05:31 +0200 Subject: * Fixed 553: @XArgsConstructor (and @Builder on a class) did not look at @Accessors to handle field accessors. * various operations on names in javac were really slow; they are faster now. --- src/core/lombok/core/TransformationsUtil.java | 5 +- .../eclipse/handlers/EclipseHandlerUtil.java | 31 +++++++++++ .../lombok/eclipse/handlers/HandleBuilder.java | 2 +- .../lombok/eclipse/handlers/HandleConstructor.java | 11 ++-- .../lombok/javac/handlers/HandleAccessors.java | 2 + src/core/lombok/javac/handlers/HandleBuilder.java | 2 +- .../lombok/javac/handlers/HandleConstructor.java | 17 ++++-- .../lombok/javac/handlers/JavacHandlerUtil.java | 31 +++++++++++ .../after-delombok/BuilderWithAccessors.java | 65 ++++++++++++++++++++++ .../after-delombok/ConstructorsWithAccessors.java | 15 +++++ .../resource/after-ecj/BuilderWithAccessors.java | 47 ++++++++++++++++ .../after-ecj/ConstructorsWithAccessors.java | 13 +++++ .../resource/before/BuilderWithAccessors.java | 7 +++ .../resource/before/ConstructorsWithAccessors.java | 6 ++ 14 files changed, 241 insertions(+), 13 deletions(-) create mode 100644 test/transform/resource/after-delombok/BuilderWithAccessors.java create mode 100644 test/transform/resource/after-delombok/ConstructorsWithAccessors.java create mode 100644 test/transform/resource/after-ecj/BuilderWithAccessors.java create mode 100644 test/transform/resource/after-ecj/ConstructorsWithAccessors.java create mode 100644 test/transform/resource/before/BuilderWithAccessors.java create mode 100644 test/transform/resource/before/ConstructorsWithAccessors.java (limited to 'test') diff --git a/src/core/lombok/core/TransformationsUtil.java b/src/core/lombok/core/TransformationsUtil.java index 8959ad7a..8c7fbd3f 100644 --- a/src/core/lombok/core/TransformationsUtil.java +++ b/src/core/lombok/core/TransformationsUtil.java @@ -70,9 +70,11 @@ public class TransformationsUtil { * @param prefixes A list of prefixes, usually provided by the {@code Accessors} settings annotation, listing field prefixes. * @return The base name of the field. */ - private static CharSequence removePrefix(CharSequence fieldName, String[] prefixes) { + public static CharSequence removePrefix(CharSequence fieldName, String[] prefixes) { if (prefixes == null || prefixes.length == 0) return fieldName; + fieldName = fieldName.toString(); + outer: for (String prefix : prefixes) { if (prefix.length() == 0) return fieldName; @@ -176,6 +178,7 @@ public class TransformationsUtil { private static String toAccessorName(AnnotationValues accessors, CharSequence fieldName, boolean isBoolean, String booleanPrefix, String normalPrefix, boolean adhereToFluent) { + fieldName = fieldName.toString(); if (fieldName.length() == 0) return null; Accessors ac = accessors == null ? null : accessors.getInstance(); diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 9bd634f7..d666084e 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1125,6 +1125,37 @@ public class EclipseHandlerUtil { return true; } + public static char[] removePrefixFromField(EclipseNode field) { + String[] prefixes = null; + for (EclipseNode node : field.down()) { + if (annotationTypeMatches(Accessors.class, node)) { + prefixes = createAnnotation(Accessors.class, node).getInstance().prefix(); + break; + } + } + + if (prefixes == null) { + EclipseNode current = field.up(); + outer: + while (current != null) { + for (EclipseNode node : current.down()) { + if (annotationTypeMatches(Accessors.class, node)) { + prefixes = createAnnotation(Accessors.class, node).getInstance().prefix(); + break outer; + } + } + current = current.up(); + } + } + + if (prefixes != null && prefixes.length > 0) { + CharSequence newName = TransformationsUtil.removePrefix(field.getName(), prefixes); + if (newName != null) return newName.toString().toCharArray(); + } + + return ((FieldDeclaration) field.get()).name; + } + public static AnnotationValues getAccessorsForField(EclipseNode field) { for (EclipseNode node : field.down()) { if (annotationTypeMatches(Accessors.class, node)) { diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java index 70110a9c..981d77dc 100644 --- a/src/core/lombok/eclipse/handlers/HandleBuilder.java +++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java @@ -113,7 +113,7 @@ public class HandleBuilder extends EclipseAnnotationHandler { // non-final fields final, but @Value's handler hasn't done this yet, so we have to do this math ourselves. // Value will only skip making a field final if it has an explicit @NonFinal annotation, so we check for that. if (fd.initialization != null && valuePresent && !hasAnnotation(NonFinal.class, fieldNode)) continue; - namesOfParameters.add(fd.name); + namesOfParameters.add(removePrefixFromField(fieldNode)); typesOfParameters.add(fd.type); fields.add(fieldNode); } diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index 1ae680d9..22285b2d 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -230,7 +230,8 @@ public class HandleConstructor { int ctr = 0; for (EclipseNode field : fields) { - fieldNames.expressions[ctr] = new StringLiteral(field.getName().toCharArray(), pS, pE, 0); + char[] fieldName = removePrefixFromField(field); + fieldNames.expressions[ctr] = new StringLiteral(fieldName, pS, pE, 0); setGeneratedBy(fieldNames.expressions[ctr], source); ctr++; } @@ -273,15 +274,17 @@ public class HandleConstructor { for (EclipseNode fieldNode : fields) { FieldDeclaration field = (FieldDeclaration) fieldNode.get(); - FieldReference thisX = new FieldReference(field.name, p); + char[] rawName = field.name; + char[] fieldName = removePrefixFromField(fieldNode); + FieldReference thisX = new FieldReference(rawName, p); thisX.receiver = new ThisReference((int)(p >> 32), (int)p); - SingleNameReference assignmentNameRef = new SingleNameReference(field.name, p); + SingleNameReference assignmentNameRef = new SingleNameReference(fieldName, p); Assignment assignment = new Assignment(thisX, assignmentNameRef, (int)p); assignment.sourceStart = (int)(p >> 32); assignment.sourceEnd = assignment.statementEnd = (int)(p >> 32); assigns.add(assignment); long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd; - Argument parameter = new Argument(field.name, fieldPos, copyType(field.type, source), Modifier.FINAL); + Argument parameter = new Argument(fieldName, fieldPos, copyType(field.type, source), Modifier.FINAL); Annotation[] nonNulls = findAnnotations(field, TransformationsUtil.NON_NULL_PATTERN); Annotation[] nullables = findAnnotations(field, TransformationsUtil.NULLABLE_PATTERN); if (nonNulls.length != 0) { diff --git a/src/core/lombok/javac/handlers/HandleAccessors.java b/src/core/lombok/javac/handlers/HandleAccessors.java index 7aeec6bb..e2489bda 100644 --- a/src/core/lombok/javac/handlers/HandleAccessors.java +++ b/src/core/lombok/javac/handlers/HandleAccessors.java @@ -28,11 +28,13 @@ import org.mangosdk.spi.ProviderFor; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.experimental.Accessors; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; @ProviderFor(JavacAnnotationHandler.class) +@HandlerPriority(65536) public class HandleAccessors extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { // Accessors itself is handled by HandleGetter/Setter; this is just to ensure that the annotation is removed diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java index 6422f5ed..7e5662cd 100644 --- a/src/core/lombok/javac/handlers/HandleBuilder.java +++ b/src/core/lombok/javac/handlers/HandleBuilder.java @@ -106,7 +106,7 @@ public class HandleBuilder extends JavacAnnotationHandler { // non-final fields final, but @Value's handler hasn't done this yet, so we have to do this math ourselves. // Value will only skip making a field final if it has an explicit @NonFinal annotation, so we check for that. if (fd.init != null && valuePresent && !hasAnnotation(NonFinal.class, fieldNode)) continue; - namesOfParameters.add(fd.name); + namesOfParameters.add(removePrefixFromField(fieldNode)); typesOfParameters.add(fd.vartype); allFields.append(fieldNode); } diff --git a/src/core/lombok/javac/handlers/HandleConstructor.java b/src/core/lombok/javac/handlers/HandleConstructor.java index ecd982e9..df8739de 100644 --- a/src/core/lombok/javac/handlers/HandleConstructor.java +++ b/src/core/lombok/javac/handlers/HandleConstructor.java @@ -52,6 +52,7 @@ import com.sun.tools.javac.tree.JCTree.JCTypeParameter; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.ListBuffer; +import com.sun.tools.javac.util.Name; public class HandleConstructor { @ProviderFor(JavacAnnotationHandler.class) @@ -210,7 +211,8 @@ public class HandleConstructor { JCExpression constructorPropertiesType = chainDots(node, "java", "beans", "ConstructorProperties"); ListBuffer fieldNames = ListBuffer.lb(); for (JavacNode field : fields) { - fieldNames.append(maker.Literal(field.getName())); + Name fieldName = removePrefixFromField(field); + fieldNames.append(maker.Literal(fieldName.toString())); } JCExpression fieldNamesArray = maker.NewArray(null, List.nil(), fieldNames.toList()); JCAnnotation annotation = maker.Annotation(constructorPropertiesType, List.of(fieldNamesArray)); @@ -229,12 +231,14 @@ public class HandleConstructor { for (JavacNode fieldNode : fields) { JCVariableDecl field = (JCVariableDecl) fieldNode.get(); + Name fieldName = removePrefixFromField(fieldNode); + Name rawName = field.name; List nonNulls = findAnnotations(fieldNode, TransformationsUtil.NON_NULL_PATTERN); List nullables = findAnnotations(fieldNode, TransformationsUtil.NULLABLE_PATTERN); - JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.FINAL, nonNulls.appendList(nullables)), field.name, field.vartype, null); + JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.FINAL, nonNulls.appendList(nullables)), fieldName, field.vartype, null); params.append(param); - JCFieldAccess thisX = maker.Select(maker.Ident(fieldNode.toName("this")), field.name); - JCAssign assign = maker.Assign(thisX, maker.Ident(field.name)); + JCFieldAccess thisX = maker.Select(maker.Ident(fieldNode.toName("this")), rawName); + JCAssign assign = maker.Assign(thisX, maker.Ident(fieldName)); assigns.append(maker.Exec(assign)); if (!nonNulls.isEmpty()) { @@ -289,12 +293,13 @@ public class HandleConstructor { for (JavacNode fieldNode : fields) { JCVariableDecl field = (JCVariableDecl) fieldNode.get(); + Name fieldName = removePrefixFromField(fieldNode); JCExpression pType = cloneType(maker, field.vartype, source); List nonNulls = findAnnotations(fieldNode, TransformationsUtil.NON_NULL_PATTERN); List nullables = findAnnotations(fieldNode, TransformationsUtil.NULLABLE_PATTERN); - JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.FINAL, nonNulls.appendList(nullables)), field.name, pType, null); + JCVariableDecl param = maker.VarDef(maker.Modifiers(Flags.FINAL, nonNulls.appendList(nullables)), fieldName, pType, null); params.append(param); - args.append(maker.Ident(field.name)); + args.append(maker.Ident(fieldName)); } JCReturn returnStatement = maker.Return(maker.NewClass(null, List.nil(), constructorType, args.toList(), null)); JCBlock body = maker.Block(0, List.of(returnStatement)); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index d7d29da2..ae3fddbf 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -456,6 +456,37 @@ public class JavacHandlerUtil { return varType != null && varType.toString().equals("boolean"); } + public static Name removePrefixFromField(JavacNode field) { + String[] prefixes = null; + for (JavacNode node : field.down()) { + if (annotationTypeMatches(Accessors.class, node)) { + prefixes = createAnnotation(Accessors.class, node).getInstance().prefix(); + break; + } + } + + if (prefixes == null) { + JavacNode current = field.up(); + outer: + while (current != null) { + for (JavacNode node : current.down()) { + if (annotationTypeMatches(Accessors.class, node)) { + prefixes = createAnnotation(Accessors.class, node).getInstance().prefix(); + break outer; + } + } + current = current.up(); + } + } + + if (prefixes != null && prefixes.length > 0) { + CharSequence newName = TransformationsUtil.removePrefix(field.getName(), prefixes); + if (newName != null) return field.toName(newName.toString()); + } + + return ((JCVariableDecl) field.get()).name; + } + public static AnnotationValues getAccessorsForField(JavacNode field) { for (JavacNode node : field.down()) { if (annotationTypeMatches(Accessors.class, node)) { diff --git a/test/transform/resource/after-delombok/BuilderWithAccessors.java b/test/transform/resource/after-delombok/BuilderWithAccessors.java new file mode 100644 index 00000000..503c33be --- /dev/null +++ b/test/transform/resource/after-delombok/BuilderWithAccessors.java @@ -0,0 +1,65 @@ +class BuilderWithAccessors { + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; + @java.lang.SuppressWarnings("all") + BuilderWithAccessors(final int plower, final int upper, final int foo, final int _bar) { + this.plower = plower; + this.pUpper = upper; + this._foo = foo; + this.__bar = _bar; + } + @java.lang.SuppressWarnings("all") + public static class BuilderWithAccessorsBuilder { + private int plower; + private int upper; + private int foo; + private int _bar; + + @java.lang.SuppressWarnings("all") + BuilderWithAccessorsBuilder() { + + } + + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsBuilder plower(final int plower) { + this.plower = plower; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsBuilder upper(final int upper) { + this.upper = upper; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsBuilder foo(final int foo) { + this.foo = foo; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderWithAccessorsBuilder _bar(final int _bar) { + this._bar = _bar; + return this; + } + + @java.lang.SuppressWarnings("all") + public BuilderWithAccessors build() { + return new BuilderWithAccessors(plower, upper, foo, _bar); + } + + @java.lang.Override + @java.lang.SuppressWarnings("all") + public java.lang.String toString() { + return "BuilderWithAccessors.BuilderWithAccessorsBuilder(plower=" + this.plower + ", upper=" + this.upper + ", foo=" + this.foo + ", _bar=" + this._bar + ")"; + } + } + + @java.lang.SuppressWarnings("all") + public static BuilderWithAccessorsBuilder builder() { + return new BuilderWithAccessorsBuilder(); + } +} \ No newline at end of file diff --git a/test/transform/resource/after-delombok/ConstructorsWithAccessors.java b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java new file mode 100644 index 00000000..9937c7ee --- /dev/null +++ b/test/transform/resource/after-delombok/ConstructorsWithAccessors.java @@ -0,0 +1,15 @@ +class ConstructorsWithAccessors { + int plower; + int pUpper; + int _huh; + int __huh2; + + @java.beans.ConstructorProperties({"plower", "upper", "huh", "_huh2"}) + @java.lang.SuppressWarnings("all") + public ConstructorsWithAccessors(final int plower, final int upper, final int huh, final int _huh2) { + this.plower = plower; + this.pUpper = upper; + this._huh = huh; + this.__huh2 = _huh2; + } +} diff --git a/test/transform/resource/after-ecj/BuilderWithAccessors.java b/test/transform/resource/after-ecj/BuilderWithAccessors.java new file mode 100644 index 00000000..79776dc4 --- /dev/null +++ b/test/transform/resource/after-ecj/BuilderWithAccessors.java @@ -0,0 +1,47 @@ +@lombok.experimental.Builder @lombok.experimental.Accessors(prefix = {"p", "_"}) class BuilderWithAccessors { + public static @java.lang.SuppressWarnings("all") class BuilderWithAccessorsBuilder { + private int plower; + private int upper; + private int foo; + private int _bar; + @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder() { + super(); + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder plower(final int plower) { + this.plower = plower; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder upper(final int upper) { + this.upper = upper; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder foo(final int foo) { + this.foo = foo; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder _bar(final int _bar) { + this._bar = _bar; + return this; + } + public @java.lang.SuppressWarnings("all") BuilderWithAccessors build() { + return new BuilderWithAccessors(plower, upper, foo, _bar); + } + public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() { + return (((((((("BuilderWithAccessors.BuilderWithAccessorsBuilder(plower=" + this.plower) + ", upper=") + this.upper) + ", foo=") + this.foo) + ", _bar=") + this._bar) + ")"); + } + } + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; + @java.lang.SuppressWarnings("all") BuilderWithAccessors(final int plower, final int upper, final int foo, final int _bar) { + super(); + this.plower = plower; + this.pUpper = upper; + this._foo = foo; + this.__bar = _bar; + } + public static @java.lang.SuppressWarnings("all") BuilderWithAccessorsBuilder builder() { + return new BuilderWithAccessorsBuilder(); + } +} diff --git a/test/transform/resource/after-ecj/ConstructorsWithAccessors.java b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java new file mode 100644 index 00000000..0df8fbe1 --- /dev/null +++ b/test/transform/resource/after-ecj/ConstructorsWithAccessors.java @@ -0,0 +1,13 @@ +@lombok.AllArgsConstructor @lombok.experimental.Accessors(prefix = {"p", "_"}) class ConstructorsWithAccessors { + int plower; + int pUpper; + int _huh; + int __huh2; + public @java.beans.ConstructorProperties({"plower", "upper", "huh", "_huh2"}) @java.lang.SuppressWarnings("all") ConstructorsWithAccessors(final int plower, final int upper, final int huh, final int _huh2) { + super(); + this.plower = plower; + this.pUpper = upper; + this._huh = huh; + this.__huh2 = _huh2; + } +} diff --git a/test/transform/resource/before/BuilderWithAccessors.java b/test/transform/resource/before/BuilderWithAccessors.java new file mode 100644 index 00000000..4f5660a1 --- /dev/null +++ b/test/transform/resource/before/BuilderWithAccessors.java @@ -0,0 +1,7 @@ +@lombok.experimental.Builder @lombok.experimental.Accessors(prefix={"p", "_"}) +class BuilderWithAccessors { + private final int plower; + private final int pUpper; + private int _foo; + private int __bar; +} diff --git a/test/transform/resource/before/ConstructorsWithAccessors.java b/test/transform/resource/before/ConstructorsWithAccessors.java new file mode 100644 index 00000000..d242317d --- /dev/null +++ b/test/transform/resource/before/ConstructorsWithAccessors.java @@ -0,0 +1,6 @@ +@lombok.AllArgsConstructor @lombok.experimental.Accessors(prefix={"p", "_"}) class ConstructorsWithAccessors { + int plower; + int pUpper; + int _huh; + int __huh2; +} -- cgit From bad93ae677622c79883f658a53484d455e36ce9a Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 19 Aug 2013 23:50:57 +0200 Subject: Only look at the line number for errors and warnings. --- src/core/lombok/javac/CapturingDiagnosticListener.java | 15 +++------------ test/core/src/lombok/CompilerMessageMatcher.java | 14 +++++--------- test/core/src/lombok/RunTestsViaEcj.java | 2 +- .../resource/messages-delombok/Accessors.java.messages | 2 +- .../messages-delombok/BuilderInvalidUse.java.messages | 4 ++-- .../ConflictingStaticConstructorNames.java.messages | 2 +- .../EqualsAndHashCodeWithExistingMethods.java.messages | 6 +++--- ...qualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- .../messages-delombok/FieldDefaultsNoop.java.messages | 2 +- .../messages-delombok/GetterAlreadyExists.java.messages | 16 ++++++++-------- .../messages-delombok/GetterBoolean.java.messages | 2 +- .../messages-delombok/GetterLazyInvalid.java.messages | 12 ++++++------ .../messages-delombok/GetterOnMethodErrors.java.messages | 2 +- .../GetterOnMethodErrors2.java.messages | 8 ++++---- .../LoggerSlf4jAlreadyExists.java.messages | 2 +- .../LoggerSlf4jOnNonStaticInnerClass.java.messages | 2 +- .../messages-delombok/LoggerSlf4jOnNonType.java.messages | 2 +- .../messages-delombok/LoggerSlf4jTypes.java.messages | 4 ++-- .../messages-delombok/NonNullOnParameter.java.messages | 2 +- .../messages-delombok/NonNullPlain.java.messages | 2 +- .../messages-delombok/SetterAlreadyExists.java.messages | 14 +++++++------- .../messages-delombok/SetterOnMethod.java.messages | 14 +++++++------- .../messages-delombok/SetterOnParam.java.messages | 14 +++++++------- .../SetterOnParamAndOnMethod.java.messages | 4 ++-- .../messages-delombok/SimpleTypeResolution.java.messages | 2 +- .../SynchronizedNameNoSuchField.java.messages | 2 +- .../SynchronizedNameStaticToInstanceRef.java.messages | 2 +- .../resource/messages-delombok/ValErrors.java.messages | 4 ++-- .../messages-delombok/ValInBasicFor.java.messages | 2 +- .../messages-delombok/WitherAlreadyExists.java.messages | 14 +++++++------- .../messages-delombok/WitherOnStatic.java.messages | 4 ++-- .../messages-delombok/WitherWithDollar.java.messages | 2 +- .../resource/messages-ecj/Accessors.java.messages | 2 +- .../messages-ecj/BuilderInvalidUse.java.messages | 4 ++-- .../ConflictingStaticConstructorNames.java.messages | 2 +- .../EqualsAndHashCodeWithExistingMethods.java.messages | 6 +++--- ...qualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- .../messages-ecj/FieldDefaultsNoop.java.messages | 2 +- .../messages-ecj/GetterAlreadyExists.java.messages | 16 ++++++++-------- .../resource/messages-ecj/GetterBoolean.java.messages | 2 +- .../messages-ecj/GetterLazyInvalid.java.messages | 12 ++++++------ .../messages-ecj/GetterOnMethodErrors.java.messages | 2 +- .../messages-ecj/GetterOnMethodErrors2.java.messages | 8 ++++---- .../messages-ecj/LoggerSlf4jAlreadyExists.java.messages | 2 +- .../LoggerSlf4jOnNonStaticInnerClass.java.messages | 2 +- .../messages-ecj/LoggerSlf4jOnNonType.java.messages | 2 +- .../resource/messages-ecj/LoggerSlf4jTypes.java.messages | 4 ++-- .../messages-ecj/NonNullOnParameter.java.messages | 6 +++--- .../resource/messages-ecj/NonNullPlain.java.messages | 2 +- .../messages-ecj/SetterAlreadyExists.java.messages | 14 +++++++------- .../resource/messages-ecj/SetterOnMethod.java.messages | 4 ++-- .../resource/messages-ecj/SetterOnParam.java.messages | 4 ++-- .../messages-ecj/SimpleTypeResolution.java.messages | 2 +- .../resource/messages-ecj/SynchronizedName.java.messages | 2 +- .../SynchronizedNameNoSuchField.java.messages | 2 +- .../SynchronizedNameStaticToInstanceRef.java.messages | 2 +- .../resource/messages-ecj/ValErrors.java.messages | 4 ++-- .../resource/messages-ecj/ValInBasicFor.java.messages | 8 ++++---- .../resource/messages-ecj/ValRawType.java.messages | 2 +- .../messages-ecj/ValueExperimental.java.messages | 2 +- .../messages-ecj/WitherAlreadyExists.java.messages | 14 +++++++------- .../resource/messages-ecj/WitherOnStatic.java.messages | 4 ++-- .../resource/messages-ecj/WitherWithDollar.java.messages | 2 +- .../messages-idempotent/NonNullOnParameter.java.messages | 2 +- .../messages-idempotent/NonNullPlain.java.messages | 6 +++--- .../SimpleTypeResolution.java.messages | 2 +- .../SynchronizedNameStaticToInstanceRef.java.messages | 2 +- .../resource/messages-idempotent/ValErrors.java.messages | 6 +++--- .../messages-idempotent/ValInBasicFor.java.messages | 2 +- 69 files changed, 167 insertions(+), 180 deletions(-) (limited to 'test') diff --git a/src/core/lombok/javac/CapturingDiagnosticListener.java b/src/core/lombok/javac/CapturingDiagnosticListener.java index 45b4047a..a0ac6adc 100644 --- a/src/core/lombok/javac/CapturingDiagnosticListener.java +++ b/src/core/lombok/javac/CapturingDiagnosticListener.java @@ -52,7 +52,7 @@ public class CapturingDiagnosticListener implements DiagnosticListener>> 32)); result = prime * result + ((message == null) ? 0 : message.hashCode()); - result = prime * result + (int) (columnOrPosition ^ (columnOrPosition >>> 32)); return result; } @@ -121,12 +113,11 @@ public class CapturingDiagnosticListener implements DiagnosticListener messageParts; - public CompilerMessageMatcher(long line, long position, String message) { + public CompilerMessageMatcher(long line, String message) { this.line = line; - this.position = position; this.messageParts = Arrays.asList(message.split("\\s+")); } public static CompilerMessageMatcher asCompilerMessageMatcher(CompilerMessage message) { - return new CompilerMessageMatcher(message.getLine(), message.getColumnOrPosition(), message.getMessage()); + return new CompilerMessageMatcher(message.getLine(), message.getMessage()); } @Override public String toString() { StringBuilder parts = new StringBuilder(); for (String part : messageParts) parts.append(part).append(" "); if (parts.length() > 0) parts.setLength(parts.length() - 1); - return String.format("%d:%d %s", line, position, parts); + return String.format("%d %s", line, parts); } public boolean matches(CompilerMessage message) { if (message.getLine() != this.line) return false; - if (message.getColumnOrPosition() != this.position) return false; for (String token : messageParts) { if (!message.getMessage().contains(token)) return false; } @@ -78,12 +74,12 @@ public class CompilerMessageMatcher { return out; } - private static final Pattern PATTERN = Pattern.compile("^(\\d+):(\\d+) (.*)$"); + private static final Pattern PATTERN = Pattern.compile("^(\\d+) (.*)$"); private static CompilerMessageMatcher read(String line) { line = line.trim(); if (line.isEmpty()) return null; Matcher m = PATTERN.matcher(line); if (!m.matches()) throw new IllegalArgumentException("Typo in test file: " + line); - return new CompilerMessageMatcher(Integer.parseInt(m.group(1)), Integer.parseInt(m.group(2)), m.group(3)); + return new CompilerMessageMatcher(Integer.parseInt(m.group(1)), m.group(2)); } } diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java index f7294f1f..586c124a 100644 --- a/test/core/src/lombok/RunTestsViaEcj.java +++ b/test/core/src/lombok/RunTestsViaEcj.java @@ -112,7 +112,7 @@ public class RunTestsViaEcj extends AbstractRunTests { CategorizedProblem[] problems = compilationResult.getAllProblems(); if (problems != null) for (CategorizedProblem p : problems) { - messages.add(new CompilerMessage(p.getSourceLineNumber(), p.getSourceStart(), p.getSourceStart(), p.isError(), p.getMessage())); + messages.add(new CompilerMessage(p.getSourceLineNumber(), p.getSourceStart(), p.isError(), p.getMessage())); } CompilationUnitDeclaration cud = compilationUnit_.get(); diff --git a/test/transform/resource/messages-delombok/Accessors.java.messages b/test/transform/resource/messages-delombok/Accessors.java.messages index 367621bd..265bc745 100644 --- a/test/transform/resource/messages-delombok/Accessors.java.messages +++ b/test/transform/resource/messages-delombok/Accessors.java.messages @@ -1 +1 @@ -19:9 Not generating setter for this field: It does not fit your @Accessors prefix list. \ No newline at end of file +19 Not generating setter for this field: It does not fit your @Accessors prefix list. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages index aeeb0c86..a04b4f9b 100644 --- a/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-delombok/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -1:1 @Getter, @Setter, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. -12:1 @Value is not allowed on builder classes. \ No newline at end of file +1 @Getter, @Setter, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +12 @Value is not allowed on builder classes. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/ConflictingStaticConstructorNames.java.messages b/test/transform/resource/messages-delombok/ConflictingStaticConstructorNames.java.messages index 06b88c10..4f915bbe 100644 --- a/test/transform/resource/messages-delombok/ConflictingStaticConstructorNames.java.messages +++ b/test/transform/resource/messages-delombok/ConflictingStaticConstructorNames.java.messages @@ -1 +1 @@ -1:1 Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used. +1 Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used. diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithExistingMethods.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithExistingMethods.java.messages index 057a7521..b3490fd0 100644 --- a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithExistingMethods.java.messages +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithExistingMethods.java.messages @@ -1,3 +1,3 @@ -1:1 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). -10:1 Not generating equals and hashCode: A method with one of those names already exists. (Either all or none of these methods will be generated). -19:1 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). +1 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). +10 Not generating equals and hashCode: A method with one of those names already exists. (Either all or none of these methods will be generated). +19 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages index 9a0b29f3..f5dfd559 100644 --- a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4:1 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15:1 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). diff --git a/test/transform/resource/messages-delombok/FieldDefaultsNoop.java.messages b/test/transform/resource/messages-delombok/FieldDefaultsNoop.java.messages index ae5dd265..9fac15c4 100644 --- a/test/transform/resource/messages-delombok/FieldDefaultsNoop.java.messages +++ b/test/transform/resource/messages-delombok/FieldDefaultsNoop.java.messages @@ -1 +1 @@ -1:1 This does nothing; provide either level or makeFinal or both. \ No newline at end of file +1 This does nothing; provide either level or makeFinal or both. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages b/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages index 7a326742..7d99aa69 100644 --- a/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/GetterAlreadyExists.java.messages @@ -1,8 +1,8 @@ -8:9 Not generating isFoo(): A method with that name already exists -14:9 Not generating isFoo(): A method with that name already exists (getFoo) -32:9 Not generating getFoo(): A method with that name already exists -50:9 Not generating getFoo(): A method with that name already exists -62:9 Not generating isFoo(): A method with that name already exists -68:9 Not generating isFoo(): A method with that name already exists (getFoo) -86:9 Not generating getFoo(): A method with that name already exists -104:9 Not generating getFoo(): A method with that name already exists +8 Not generating isFoo(): A method with that name already exists +14 Not generating isFoo(): A method with that name already exists (getFoo) +32 Not generating getFoo(): A method with that name already exists +50 Not generating getFoo(): A method with that name already exists +62 Not generating isFoo(): A method with that name already exists +68 Not generating isFoo(): A method with that name already exists (getFoo) +86 Not generating getFoo(): A method with that name already exists +104 Not generating getFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-delombok/GetterBoolean.java.messages b/test/transform/resource/messages-delombok/GetterBoolean.java.messages index 91ad3512..ab9d659d 100644 --- a/test/transform/resource/messages-delombok/GetterBoolean.java.messages +++ b/test/transform/resource/messages-delombok/GetterBoolean.java.messages @@ -1 +1 @@ -13:9 Not generating isFoo(): A method with that name already exists (getFoo) \ No newline at end of file +13 Not generating isFoo(): A method with that name already exists (getFoo) \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/GetterLazyInvalid.java.messages b/test/transform/resource/messages-delombok/GetterLazyInvalid.java.messages index 5c72fd56..5cb47108 100644 --- a/test/transform/resource/messages-delombok/GetterLazyInvalid.java.messages +++ b/test/transform/resource/messages-delombok/GetterLazyInvalid.java.messages @@ -1,6 +1,6 @@ -2:9 'lazy' requires the field to be private and final. -6:9 'lazy' requires the field to be private and final. -10:9 'lazy' requires the field to be private and final. -14:9 'lazy' does not work with AccessLevel.NONE. -17:1 'lazy' is not supported for @Getter on a type. -22:9 'lazy' requires field initialization. \ No newline at end of file +2 'lazy' requires the field to be private and final. +6 'lazy' requires the field to be private and final. +10 'lazy' requires the field to be private and final. +14 'lazy' does not work with AccessLevel.NONE. +17 'lazy' is not supported for @Getter on a type. +22 'lazy' requires field initialization. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages index 4c82f730..26c30298 100644 --- a/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages +++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors.java.messages @@ -1 +1 @@ -3:1 'onMethod' is not supported for @Getter on a type. \ No newline at end of file +3 'onMethod' is not supported for @Getter on a type. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages index b5bad45b..af1e3b7a 100644 --- a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -3:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -4:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -5:9 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +2 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +3 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +4 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +5 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jAlreadyExists.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jAlreadyExists.java.messages index 8aa22226..db5f9891 100644 --- a/test/transform/resource/messages-delombok/LoggerSlf4jAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/LoggerSlf4jAlreadyExists.java.messages @@ -1 +1 @@ -1:1 Field 'log' already exists. +1 Field 'log' already exists. diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonStaticInnerClass.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonStaticInnerClass.java.messages index 570a169b..128a0c62 100644 --- a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonStaticInnerClass.java.messages +++ b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonStaticInnerClass.java.messages @@ -1 +1 @@ -2:9 @Log is not legal on non-static inner classes. \ No newline at end of file +2 @Log is not legal on non-static inner classes. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages index ebc23411..262fbb27 100644 --- a/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages +++ b/test/transform/resource/messages-delombok/LoggerSlf4jOnNonType.java.messages @@ -1 +1 @@ -2:9 @Log is legal only on types. \ No newline at end of file +2 @Log is legal only on types. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jTypes.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jTypes.java.messages index a525dd27..08f6bb7b 100644 --- a/test/transform/resource/messages-delombok/LoggerSlf4jTypes.java.messages +++ b/test/transform/resource/messages-delombok/LoggerSlf4jTypes.java.messages @@ -1,2 +1,2 @@ -1:1 @Log is legal only on classes and enums. -4:1 @Log is legal only on classes and enums. \ No newline at end of file +1 @Log is legal only on classes and enums. +4 @Log is legal only on classes and enums. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages b/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages index ac87adcd..042c97f8 100644 --- a/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-delombok/NonNullOnParameter.java.messages @@ -1 +1 @@ -22:89 @NonNull is meaningless on a primitive. +22 @NonNull is meaningless on a primitive. diff --git a/test/transform/resource/messages-delombok/NonNullPlain.java.messages b/test/transform/resource/messages-delombok/NonNullPlain.java.messages index 67eb8abe..4033f645 100644 --- a/test/transform/resource/messages-delombok/NonNullPlain.java.messages +++ b/test/transform/resource/messages-delombok/NonNullPlain.java.messages @@ -1 +1 @@ -7:9 @NonNull is meaningless on a primitive. \ No newline at end of file +8 @NonNull is meaningless on a primitive. \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages b/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages index 9cece93c..4b1e209b 100644 --- a/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/SetterAlreadyExists.java.messages @@ -1,7 +1,7 @@ -2:9 Not generating setFoo(): A method with that name already exists -8:9 Not generating setFoo(): A method with that name already exists -14:9 Not generating setFoo(): A method with that name already exists -20:9 Not generating setFoo(): A method with that name already exists -38:9 Not generating setFoo(): A method with that name already exists -44:9 Not generating setFoo(): A method with that name already exists (setIsFoo) -50:9 Not generating setFoo(): A method with that name already exists +2 Not generating setFoo(): A method with that name already exists +8 Not generating setFoo(): A method with that name already exists +14 Not generating setFoo(): A method with that name already exists +20 Not generating setFoo(): A method with that name already exists +38 Not generating setFoo(): A method with that name already exists +44 Not generating setFoo(): A method with that name already exists (setIsFoo) +50 Not generating setFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-delombok/SetterOnMethod.java.messages b/test/transform/resource/messages-delombok/SetterOnMethod.java.messages index 9473d5b3..1be8f1ea 100644 --- a/test/transform/resource/messages-delombok/SetterOnMethod.java.messages +++ b/test/transform/resource/messages-delombok/SetterOnMethod.java.messages @@ -1,7 +1,7 @@ -3:34 incompatible types -4:44 incompatible types -6:26 incompatible types -11:26 incompatible types -14:44 incompatible types -6:1 'onMethod' is not supported for @Setter on a type. -11:1 'onMethod' is not supported for @Setter on a type. +3 incompatible types +4 incompatible types +6 incompatible types +11 incompatible types +14 incompatible types +6 'onMethod' is not supported for @Setter on a type. +11 'onMethod' is not supported for @Setter on a type. diff --git a/test/transform/resource/messages-delombok/SetterOnParam.java.messages b/test/transform/resource/messages-delombok/SetterOnParam.java.messages index b8c69eca..828d9511 100644 --- a/test/transform/resource/messages-delombok/SetterOnParam.java.messages +++ b/test/transform/resource/messages-delombok/SetterOnParam.java.messages @@ -1,7 +1,7 @@ -3:33 incompatible types -4:43 incompatible types -6:25 incompatible types -11:25 incompatible types -14:43 incompatible types -6:1 'onParam' is not supported for @Setter on a type. -11:1 'onParam' is not supported for @Setter on a type. +3 incompatible types +4 incompatible types +6 incompatible types +11 incompatible types +14 incompatible types +6 'onParam' is not supported for @Setter on a type. +11 'onParam' is not supported for @Setter on a type. diff --git a/test/transform/resource/messages-delombok/SetterOnParamAndOnMethod.java.messages b/test/transform/resource/messages-delombok/SetterOnParamAndOnMethod.java.messages index 7324f6f3..86cbd0e6 100644 --- a/test/transform/resource/messages-delombok/SetterOnParamAndOnMethod.java.messages +++ b/test/transform/resource/messages-delombok/SetterOnParamAndOnMethod.java.messages @@ -1,2 +1,2 @@ -2:34 incompatible types -2:54 incompatible types +2 incompatible types +2 incompatible types diff --git a/test/transform/resource/messages-delombok/SimpleTypeResolution.java.messages b/test/transform/resource/messages-delombok/SimpleTypeResolution.java.messages index 7acd35ed..ec74f090 100644 --- a/test/transform/resource/messages-delombok/SimpleTypeResolution.java.messages +++ b/test/transform/resource/messages-delombok/SimpleTypeResolution.java.messages @@ -1 +1 @@ -2:10 cannot find symbol +2 cannot find symbol diff --git a/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages b/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages index f282d34d..ae351773 100644 --- a/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages +++ b/test/transform/resource/messages-delombok/SynchronizedNameNoSuchField.java.messages @@ -1 +1 @@ -5:9 The field write does not exist. +5 The field write does not exist. diff --git a/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages b/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages index 5d6bc958..fe0653c8 100644 --- a/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages +++ b/test/transform/resource/messages-delombok/SynchronizedNameStaticToInstanceRef.java.messages @@ -1 +1 @@ -5:9 non-static variable read cannot be referenced from a static context \ No newline at end of file +5 non-static variable read cannot be referenced from a static context \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/ValErrors.java.messages b/test/transform/resource/messages-delombok/ValErrors.java.messages index 887b8c21..bb33c6de 100644 --- a/test/transform/resource/messages-delombok/ValErrors.java.messages +++ b/test/transform/resource/messages-delombok/ValErrors.java.messages @@ -1,2 +1,2 @@ -5:21 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved -9:21 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) +5 Cannot use 'val' here because initializer expression does not have a representable type: Type cannot be resolved +9 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) diff --git a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages index 9bca1be6..7166b550 100644 --- a/test/transform/resource/messages-delombok/ValInBasicFor.java.messages +++ b/test/transform/resource/messages-delombok/ValInBasicFor.java.messages @@ -1 +1 @@ -6:53 'val' is not allowed in old-style for loops +6 'val' is not allowed in old-style for loops diff --git a/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages b/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages index b68f6398..d5e30e28 100644 --- a/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages +++ b/test/transform/resource/messages-delombok/WitherAlreadyExists.java.messages @@ -1,7 +1,7 @@ -2:9 Not generating withFoo(): A method with that name already exists -12:9 Not generating withFoo(): A method with that name already exists -22:9 Not generating withFoo(): A method with that name already exists -32:9 Not generating withFoo(): A method with that name already exists -62:9 Not generating withFoo(): A method with that name already exists -72:9 Not generating withFoo(): A method with that name already exists (withIsFoo) -82:9 Not generating withFoo(): A method with that name already exists +2 Not generating withFoo(): A method with that name already exists +12 Not generating withFoo(): A method with that name already exists +22 Not generating withFoo(): A method with that name already exists +32 Not generating withFoo(): A method with that name already exists +62 Not generating withFoo(): A method with that name already exists +72 Not generating withFoo(): A method with that name already exists (withIsFoo) +82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-delombok/WitherOnStatic.java.messages b/test/transform/resource/messages-delombok/WitherOnStatic.java.messages index 9dd69e75..3af59fa1 100644 --- a/test/transform/resource/messages-delombok/WitherOnStatic.java.messages +++ b/test/transform/resource/messages-delombok/WitherOnStatic.java.messages @@ -1,2 +1,2 @@ -2:9 Not generating wither for this field: Withers cannot be generated for static fields. -3:9 Not generating wither for this field: Withers cannot be generated for static fields. +2 Not generating wither for this field: Withers cannot be generated for static fields. +3 Not generating wither for this field: Withers cannot be generated for static fields. diff --git a/test/transform/resource/messages-delombok/WitherWithDollar.java.messages b/test/transform/resource/messages-delombok/WitherWithDollar.java.messages index 74eeabba..84603868 100644 --- a/test/transform/resource/messages-delombok/WitherWithDollar.java.messages +++ b/test/transform/resource/messages-delombok/WitherWithDollar.java.messages @@ -1 +1 @@ -2:9 Not generating wither for this field: Withers cannot be generated for fields starting with $. +2 Not generating wither for this field: Withers cannot be generated for fields starting with $. diff --git a/test/transform/resource/messages-ecj/Accessors.java.messages b/test/transform/resource/messages-ecj/Accessors.java.messages index 3e6bbd69..c955f664 100644 --- a/test/transform/resource/messages-ecj/Accessors.java.messages +++ b/test/transform/resource/messages-ecj/Accessors.java.messages @@ -1 +1 @@ -19:530 Not generating setter for this field: It does not fit your @Accessors prefix list. +19 Not generating setter for this field: It does not fit your @Accessors prefix list. diff --git a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages index 8ffc6e26..84942101 100644 --- a/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages +++ b/test/transform/resource/messages-ecj/BuilderInvalidUse.java.messages @@ -1,2 +1,2 @@ -1:0 @Getter, @Setter, @FieldDefaults, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. -12:331 @Value is not allowed on builder classes. \ No newline at end of file +1 @Getter, @Setter, @FieldDefaults, @Wither, @Data, @ToString, @EqualsAndHashCode, @AllArgsConstructor are not allowed on builder classes. +12 @Value is not allowed on builder classes. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/ConflictingStaticConstructorNames.java.messages b/test/transform/resource/messages-ecj/ConflictingStaticConstructorNames.java.messages index 50f2e97f..4f915bbe 100644 --- a/test/transform/resource/messages-ecj/ConflictingStaticConstructorNames.java.messages +++ b/test/transform/resource/messages-ecj/ConflictingStaticConstructorNames.java.messages @@ -1 +1 @@ -1:0 Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used. +1 Ignoring static constructor name: explicit @XxxArgsConstructor annotation present; its `staticName` parameter will be used. diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithExistingMethods.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithExistingMethods.java.messages index db144316..b3490fd0 100644 --- a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithExistingMethods.java.messages +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithExistingMethods.java.messages @@ -1,3 +1,3 @@ -1:0 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). -10:125 Not generating equals and hashCode: A method with one of those names already exists. (Either all or none of these methods will be generated). -19:274 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). +1 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). +10 Not generating equals and hashCode: A method with one of those names already exists. (Either all or none of these methods will be generated). +19 Not generating equals, hashCode and canEquals: A method with one of those names already exists. (Either all or none of these methods will be generated). diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages index cf6ebea2..f5dfd559 100644 --- a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4:57 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15:194 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). diff --git a/test/transform/resource/messages-ecj/FieldDefaultsNoop.java.messages b/test/transform/resource/messages-ecj/FieldDefaultsNoop.java.messages index 5903679b..9fac15c4 100644 --- a/test/transform/resource/messages-ecj/FieldDefaultsNoop.java.messages +++ b/test/transform/resource/messages-ecj/FieldDefaultsNoop.java.messages @@ -1 +1 @@ -1:0 This does nothing; provide either level or makeFinal or both. \ No newline at end of file +1 This does nothing; provide either level or makeFinal or both. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/GetterAlreadyExists.java.messages b/test/transform/resource/messages-ecj/GetterAlreadyExists.java.messages index ae62a1fb..7d99aa69 100644 --- a/test/transform/resource/messages-ecj/GetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-ecj/GetterAlreadyExists.java.messages @@ -1,8 +1,8 @@ -8:102 Not generating isFoo(): A method with that name already exists -14:186 Not generating isFoo(): A method with that name already exists (getFoo) -32:436 Not generating getFoo(): A method with that name already exists -50:688 Not generating getFoo(): A method with that name already exists -62:868 Not generating isFoo(): A method with that name already exists -68:961 Not generating isFoo(): A method with that name already exists (getFoo) -86:1240 Not generating getFoo(): A method with that name already exists -104:1510 Not generating getFoo(): A method with that name already exists +8 Not generating isFoo(): A method with that name already exists +14 Not generating isFoo(): A method with that name already exists (getFoo) +32 Not generating getFoo(): A method with that name already exists +50 Not generating getFoo(): A method with that name already exists +62 Not generating isFoo(): A method with that name already exists +68 Not generating isFoo(): A method with that name already exists (getFoo) +86 Not generating getFoo(): A method with that name already exists +104 Not generating getFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/GetterBoolean.java.messages b/test/transform/resource/messages-ecj/GetterBoolean.java.messages index 8ae086f6..8ebf0a31 100644 --- a/test/transform/resource/messages-ecj/GetterBoolean.java.messages +++ b/test/transform/resource/messages-ecj/GetterBoolean.java.messages @@ -1 +1 @@ -13:220 Not generating isFoo(): A method with that name already exists (getFoo) +13 Not generating isFoo(): A method with that name already exists (getFoo) diff --git a/test/transform/resource/messages-ecj/GetterLazyInvalid.java.messages b/test/transform/resource/messages-ecj/GetterLazyInvalid.java.messages index 9ecf0fc0..b18843e6 100644 --- a/test/transform/resource/messages-ecj/GetterLazyInvalid.java.messages +++ b/test/transform/resource/messages-ecj/GetterLazyInvalid.java.messages @@ -1,6 +1,6 @@ -2:35 'lazy' requires the field to be private and final. -6:132 'lazy' requires the field to be private and final. -10:232 'lazy' requires the field to be private and final. -14:315 'lazy' does not work with AccessLevel.NONE. -17:412 'lazy' is not supported for @Getter on a type. -22:544 'lazy' requires field initialization. +2 'lazy' requires the field to be private and final. +6 'lazy' requires the field to be private and final. +10 'lazy' requires the field to be private and final. +14 'lazy' does not work with AccessLevel.NONE. +17 'lazy' is not supported for @Getter on a type. +22 'lazy' requires field initialization. diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages index 804e8a3c..26c30298 100644 --- a/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages +++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors.java.messages @@ -1 +1 @@ -3:50 'onMethod' is not supported for @Getter on a type. \ No newline at end of file +3 'onMethod' is not supported for @Getter on a type. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages index f87b9f13..af1e3b7a 100644 --- a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2:31 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -3:93 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -4:144 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) -5:210 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +2 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +3 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +4 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +5 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jAlreadyExists.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jAlreadyExists.java.messages index 859e29d8..db5f9891 100644 --- a/test/transform/resource/messages-ecj/LoggerSlf4jAlreadyExists.java.messages +++ b/test/transform/resource/messages-ecj/LoggerSlf4jAlreadyExists.java.messages @@ -1 +1 @@ -1:0 Field 'log' already exists. +1 Field 'log' already exists. diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonStaticInnerClass.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonStaticInnerClass.java.messages index 570a169b..128a0c62 100644 --- a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonStaticInnerClass.java.messages +++ b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonStaticInnerClass.java.messages @@ -1 +1 @@ -2:9 @Log is not legal on non-static inner classes. \ No newline at end of file +2 @Log is not legal on non-static inner classes. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages index b6848135..81e9b718 100644 --- a/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages +++ b/test/transform/resource/messages-ecj/LoggerSlf4jOnNonType.java.messages @@ -1 +1 @@ -2:30 The annotation @Slf4j is disallowed for this location +2 The annotation @Slf4j is disallowed for this location diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jTypes.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jTypes.java.messages index b9f8b63f..949886d5 100644 --- a/test/transform/resource/messages-ecj/LoggerSlf4jTypes.java.messages +++ b/test/transform/resource/messages-ecj/LoggerSlf4jTypes.java.messages @@ -1,2 +1,2 @@ -1:0 @Slf4j is legal only on classes and enums. -4:67 @Slf4j is legal only on classes and enums. +1 @Slf4j is legal only on classes and enums. +4 @Slf4j is legal only on classes and enums. diff --git a/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages b/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages index 1539929b..4b7d18b3 100644 --- a/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-ecj/NonNullOnParameter.java.messages @@ -1,3 +1,3 @@ -15:460 Dead code -22:683 @NonNull is meaningless on a primitive. -28:823 Dead code \ No newline at end of file +15 Dead code +22 @NonNull is meaningless on a primitive. +28 Dead code \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/NonNullPlain.java.messages b/test/transform/resource/messages-ecj/NonNullPlain.java.messages index 96eed252..1c33c701 100644 --- a/test/transform/resource/messages-ecj/NonNullPlain.java.messages +++ b/test/transform/resource/messages-ecj/NonNullPlain.java.messages @@ -1 +1 @@ -7:116 @NonNull is meaningless on a primitive. \ No newline at end of file +7 @NonNull is meaningless on a primitive. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages b/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages index 5fc0a365..4b1e209b 100644 --- a/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages +++ b/test/transform/resource/messages-ecj/SetterAlreadyExists.java.messages @@ -1,7 +1,7 @@ -2:17 Not generating setFoo(): A method with that name already exists -8:96 Not generating setFoo(): A method with that name already exists -14:174 Not generating setFoo(): A method with that name already exists -20:252 Not generating setFoo(): A method with that name already exists -38:480 Not generating setFoo(): A method with that name already exists -44:570 Not generating setFoo(): A method with that name already exists (setIsFoo) -50:653 Not generating setFoo(): A method with that name already exists +2 Not generating setFoo(): A method with that name already exists +8 Not generating setFoo(): A method with that name already exists +14 Not generating setFoo(): A method with that name already exists +20 Not generating setFoo(): A method with that name already exists +38 Not generating setFoo(): A method with that name already exists +44 Not generating setFoo(): A method with that name already exists (setIsFoo) +50 Not generating setFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/SetterOnMethod.java.messages b/test/transform/resource/messages-ecj/SetterOnMethod.java.messages index ecfa3f69..8e7ff7f8 100644 --- a/test/transform/resource/messages-ecj/SetterOnMethod.java.messages +++ b/test/transform/resource/messages-ecj/SetterOnMethod.java.messages @@ -1,2 +1,2 @@ -6:0 'onMethod' is not supported for @Setter on a type. -11:0 'onMethod' is not supported for @Setter on a type. \ No newline at end of file +6 'onMethod' is not supported for @Setter on a type. +11 'onMethod' is not supported for @Setter on a type. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/SetterOnParam.java.messages b/test/transform/resource/messages-ecj/SetterOnParam.java.messages index 7d0c4a1e..dbab4caa 100644 --- a/test/transform/resource/messages-ecj/SetterOnParam.java.messages +++ b/test/transform/resource/messages-ecj/SetterOnParam.java.messages @@ -1,2 +1,2 @@ -6:0 'onParam' is not supported for @Setter on a type. -11:0 'onParam' is not supported for @Setter on a type. \ No newline at end of file +6 'onParam' is not supported for @Setter on a type. +11 'onParam' is not supported for @Setter on a type. \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/SimpleTypeResolution.java.messages b/test/transform/resource/messages-ecj/SimpleTypeResolution.java.messages index eb33b0df..87edc6c2 100644 --- a/test/transform/resource/messages-ecj/SimpleTypeResolution.java.messages +++ b/test/transform/resource/messages-ecj/SimpleTypeResolution.java.messages @@ -1 +1 @@ -2:35 Getter cannot be resolved to a type +2 Getter cannot be resolved to a type diff --git a/test/transform/resource/messages-ecj/SynchronizedName.java.messages b/test/transform/resource/messages-ecj/SynchronizedName.java.messages index 0ad3be0a..5322f9d2 100644 --- a/test/transform/resource/messages-ecj/SynchronizedName.java.messages +++ b/test/transform/resource/messages-ecj/SynchronizedName.java.messages @@ -1 +1 @@ -8:185 The static field SynchronizedName.READ should be accessed in a static way +8 The static field SynchronizedName.READ should be accessed in a static way diff --git a/test/transform/resource/messages-ecj/SynchronizedNameNoSuchField.java.messages b/test/transform/resource/messages-ecj/SynchronizedNameNoSuchField.java.messages index b07f020c..ae351773 100644 --- a/test/transform/resource/messages-ecj/SynchronizedNameNoSuchField.java.messages +++ b/test/transform/resource/messages-ecj/SynchronizedNameNoSuchField.java.messages @@ -1 +1 @@ -5:120 The field write does not exist. +5 The field write does not exist. diff --git a/test/transform/resource/messages-ecj/SynchronizedNameStaticToInstanceRef.java.messages b/test/transform/resource/messages-ecj/SynchronizedNameStaticToInstanceRef.java.messages index 834877ef..98b9c948 100644 --- a/test/transform/resource/messages-ecj/SynchronizedNameStaticToInstanceRef.java.messages +++ b/test/transform/resource/messages-ecj/SynchronizedNameStaticToInstanceRef.java.messages @@ -1 +1 @@ -5:127 Cannot make a static reference to the non-static field SynchronizedNameStaticToInstanceRef.read +5 Cannot make a static reference to the non-static field SynchronizedNameStaticToInstanceRef.read diff --git a/test/transform/resource/messages-ecj/ValErrors.java.messages b/test/transform/resource/messages-ecj/ValErrors.java.messages index fda58094..6d53ddd6 100644 --- a/test/transform/resource/messages-ecj/ValErrors.java.messages +++ b/test/transform/resource/messages-ecj/ValErrors.java.messages @@ -1,2 +1,2 @@ -5:95 d cannot be resolved to a variable -9:143 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) +5 d cannot be resolved to a variable +9 'val' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... }) diff --git a/test/transform/resource/messages-ecj/ValInBasicFor.java.messages b/test/transform/resource/messages-ecj/ValInBasicFor.java.messages index 068d72b9..43cd7ce8 100644 --- a/test/transform/resource/messages-ecj/ValInBasicFor.java.messages +++ b/test/transform/resource/messages-ecj/ValInBasicFor.java.messages @@ -1,4 +1,4 @@ -6:160 'val' is not allowed in old-style for loops -6:171 Type mismatch: cannot convert from int to val -6:174 'val' is not allowed in old-style for loops -6:187 'val' is not allowed in old-style for loops +6 'val' is not allowed in old-style for loops +6 Type mismatch: cannot convert from int to val +6 'val' is not allowed in old-style for loops +6 'val' is not allowed in old-style for loops diff --git a/test/transform/resource/messages-ecj/ValRawType.java.messages b/test/transform/resource/messages-ecj/ValRawType.java.messages index b7669ede..2a1fbba6 100644 --- a/test/transform/resource/messages-ecj/ValRawType.java.messages +++ b/test/transform/resource/messages-ecj/ValRawType.java.messages @@ -1 +1 @@ -13:260 List is a raw type. References to generic type List should be parameterized +13 List is a raw type. References to generic type List should be parameterized diff --git a/test/transform/resource/messages-ecj/ValueExperimental.java.messages b/test/transform/resource/messages-ecj/ValueExperimental.java.messages index db4520ca..e454a878 100644 --- a/test/transform/resource/messages-ecj/ValueExperimental.java.messages +++ b/test/transform/resource/messages-ecj/ValueExperimental.java.messages @@ -1 +1 @@ -1:7 The type Value is deprecated \ No newline at end of file +1 The type Value is deprecated \ No newline at end of file diff --git a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages b/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages index 87459eb2..d5e30e28 100644 --- a/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages +++ b/test/transform/resource/messages-ecj/WitherAlreadyExists.java.messages @@ -1,7 +1,7 @@ -2:17 Not generating withFoo(): A method with that name already exists -12:141 Not generating withFoo(): A method with that name already exists -22:264 Not generating withFoo(): A method with that name already exists -32:386 Not generating withFoo(): A method with that name already exists -62:746 Not generating withFoo(): A method with that name already exists -72:880 Not generating withFoo(): A method with that name already exists (withIsFoo) -82:1008 Not generating withFoo(): A method with that name already exists +2 Not generating withFoo(): A method with that name already exists +12 Not generating withFoo(): A method with that name already exists +22 Not generating withFoo(): A method with that name already exists +32 Not generating withFoo(): A method with that name already exists +62 Not generating withFoo(): A method with that name already exists +72 Not generating withFoo(): A method with that name already exists (withIsFoo) +82 Not generating withFoo(): A method with that name already exists diff --git a/test/transform/resource/messages-ecj/WitherOnStatic.java.messages b/test/transform/resource/messages-ecj/WitherOnStatic.java.messages index 72e39f62..3af59fa1 100644 --- a/test/transform/resource/messages-ecj/WitherOnStatic.java.messages +++ b/test/transform/resource/messages-ecj/WitherOnStatic.java.messages @@ -1,2 +1,2 @@ -2:24 Not generating wither for this field: Withers cannot be generated for static fields. -3:73 Not generating wither for this field: Withers cannot be generated for static fields. +2 Not generating wither for this field: Withers cannot be generated for static fields. +3 Not generating wither for this field: Withers cannot be generated for static fields. diff --git a/test/transform/resource/messages-ecj/WitherWithDollar.java.messages b/test/transform/resource/messages-ecj/WitherWithDollar.java.messages index 93203dbb..84603868 100644 --- a/test/transform/resource/messages-ecj/WitherWithDollar.java.messages +++ b/test/transform/resource/messages-ecj/WitherWithDollar.java.messages @@ -1 +1 @@ -2:26 Not generating wither for this field: Withers cannot be generated for fields starting with $. +2 Not generating wither for this field: Withers cannot be generated for fields starting with $. diff --git a/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages b/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages index fd23a32a..57556bf3 100644 --- a/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages +++ b/test/transform/resource/messages-idempotent/NonNullOnParameter.java.messages @@ -1 +1 @@ -33:89 @NonNull is meaningless on a primitive. \ No newline at end of file +33 @NonNull is meaningless on a primitive. \ No newline at end of file diff --git a/test/transform/resource/messages-idempotent/NonNullPlain.java.messages b/test/transform/resource/messages-idempotent/NonNullPlain.java.messages index c48da311..1d8c4d9c 100644 --- a/test/transform/resource/messages-idempotent/NonNullPlain.java.messages +++ b/test/transform/resource/messages-idempotent/NonNullPlain.java.messages @@ -1,3 +1,3 @@ -4:9 @NonNull is meaningless on a primitive. -18:29 @NonNull is meaningless on a primitive. -44:26 @NonNull is meaningless on a primitive. \ No newline at end of file +3 @NonNull is meaningless on a primitive. +15 @NonNull is meaningless on a primitive. +37 @NonNull is meaningless on a primitive. \ No newline at end of file diff --git a/test/transform/resource/messages-idempotent/SimpleTypeResolution.java.messages b/test/transform/resource/messages-idempotent/SimpleTypeResolution.java.messages index 7acd35ed..ec74f090 100644 --- a/test/transform/resource/messages-idempotent/SimpleTypeResolution.java.messages +++ b/test/transform/resource/messages-idempotent/SimpleTypeResolution.java.messages @@ -1 +1 @@ -2:10 cannot find symbol +2 cannot find symbol diff --git a/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages b/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages index ed3eccb1..53b39d98 100644 --- a/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages +++ b/test/transform/resource/messages-idempotent/SynchronizedNameStaticToInstanceRef.java.messages @@ -1 +1 @@ -5:66 non-static variable read cannot be referenced from a static context +5 non-static variable read cannot be referenced from a static context diff --git a/test/transform/resource/messages-idempotent/ValErrors.java.messages b/test/transform/resource/messages-idempotent/ValErrors.java.messages index 9bee37d4..c2432c6a 100644 --- a/test/transform/resource/messages-idempotent/ValErrors.java.messages +++ b/test/transform/resource/messages-idempotent/ValErrors.java.messages @@ -1,3 +1,3 @@ -3:44 cannot find symbol -6:17 cannot find symbol -6:25 illegal initializer for +3 cannot find symbol +6 cannot find symbol +6 illegal initializer for diff --git a/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages b/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages index fb675485..67842eb9 100644 --- a/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages +++ b/test/transform/resource/messages-idempotent/ValInBasicFor.java.messages @@ -1 +1 @@ -5:53 'val' is not allowed in old-style for loops +5 'val' is not allowed in old-style for loops -- cgit From d1b26ab164bcd9e9a17c7c0b00f711de66602690 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 19 Aug 2013 23:55:52 +0200 Subject: Removed blanks --- test/transform/resource/after-delombok/NonNullPlain.java | 9 --------- 1 file changed, 9 deletions(-) (limited to 'test') diff --git a/test/transform/resource/after-delombok/NonNullPlain.java b/test/transform/resource/after-delombok/NonNullPlain.java index 6b85cbf7..b7d27ef3 100644 --- a/test/transform/resource/after-delombok/NonNullPlain.java +++ b/test/transform/resource/after-delombok/NonNullPlain.java @@ -1,5 +1,4 @@ import java.lang.annotation.*; - class NonNullPlain { @lombok.NonNull int i; @@ -7,12 +6,10 @@ class NonNullPlain { String s; @NotNull Object o; - @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE}) @Retention(RetentionPolicy.CLASS) public @interface NotNull { } - @java.beans.ConstructorProperties({"i", "s"}) @java.lang.SuppressWarnings("all") public NonNullPlain(@lombok.NonNull final int i, @lombok.NonNull final String s) { @@ -22,29 +19,24 @@ class NonNullPlain { this.i = i; this.s = s; } - @lombok.NonNull @java.lang.SuppressWarnings("all") public int getI() { return this.i; } - @lombok.NonNull @java.lang.SuppressWarnings("all") public String getS() { return this.s; } - @java.lang.SuppressWarnings("all") public Object getO() { return this.o; } - @java.lang.SuppressWarnings("all") public void setI(@lombok.NonNull final int i) { this.i = i; } - @java.lang.SuppressWarnings("all") public void setS(@lombok.NonNull final String s) { if (s == null) { @@ -52,7 +44,6 @@ class NonNullPlain { } this.s = s; } - @java.lang.SuppressWarnings("all") public void setO(final Object o) { this.o = o; -- cgit From 6a02cb40137788e6f77919c762b72b3d5880d2da Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 9 Sep 2013 23:54:28 +0200 Subject: [jdk8support] We now handle doc comments internally, alleviating the need to try and keep up with the complete rewrites of the doc comment parser from java6 to java7 to java8. Still doesn't actually work in jdk8, but only because of a last-mile issue. (we communicate the doc comment via compilationUnit.docComments but that changed types in jdk8, we just need to make a wrapper to make that work). --- src/delombok/lombok/delombok/Delombok.java | 4 + .../lombok/delombok/DocCommentIntegrator.java | 97 ++++++++++++++++++++++ .../lombok/delombok/PrettyCommentsPrinter.java | 42 ++-------- src/utils/lombok/javac/CommentCatcher.java | 13 ++- src/utils/lombok/javac/Javac.java | 11 +++ .../after-delombok/GetterSetterJavadoc.java | 12 +-- .../resource/before/GetterSetterJavadoc.java | 12 +-- 7 files changed, 143 insertions(+), 48 deletions(-) create mode 100644 src/delombok/lombok/delombok/DocCommentIntegrator.java (limited to 'test') diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java index 1fae4560..0128e44f 100644 --- a/src/delombok/lombok/delombok/Delombok.java +++ b/src/delombok/lombok/delombok/Delombok.java @@ -383,6 +383,10 @@ public class Delombok { return false; } + for (JCCompilationUnit unit : roots) { + catcher.setComments(unit, new DocCommentIntegrator().integrate(catcher.getComments(unit), unit)); + } + com.sun.tools.javac.util.List trees = compiler.enterTrees(toJavacList(roots)); JavaCompiler delegate = compiler.processAnnotations(trees); diff --git a/src/delombok/lombok/delombok/DocCommentIntegrator.java b/src/delombok/lombok/delombok/DocCommentIntegrator.java new file mode 100644 index 00000000..80aec16a --- /dev/null +++ b/src/delombok/lombok/delombok/DocCommentIntegrator.java @@ -0,0 +1,97 @@ +package lombok.delombok; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.regex.Pattern; + +import lombok.javac.CommentInfo; +import lombok.javac.Javac; + +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; + +public class DocCommentIntegrator { + /** + * Returns the same comment list as when this integrator was created, minus all doc comments that have been successfully integrated into the compilation unit. + */ + public List integrate(List comments, JCCompilationUnit unit) { + List out = new ArrayList(); + CommentInfo lastExcisedComment = null; + JCTree lastNode = null; + + for (CommentInfo cmt : comments) { + if (!cmt.isJavadoc()) { + out.add(cmt); + continue; + } + + JCTree node = findJavadocableNodeOnOrAfter(unit, cmt.endPos); + if (node == null) { + out.add(cmt); + continue; + } + + if (node == lastNode) { + out.add(lastExcisedComment); + } + if (!attach(unit, node, cmt)) { + out.add(cmt); + } else { + lastNode = node; + lastExcisedComment = cmt; + } + } + return out; + } + + private static final Pattern CONTENT_STRIPPER = Pattern.compile("^(?:\\s*\\*)?[ \\t]*(.*?)$", Pattern.MULTILINE); + @SuppressWarnings("unchecked") private boolean attach(JCCompilationUnit top, JCTree node, CommentInfo cmt) { + String docCommentContent = cmt.content; + if (docCommentContent.startsWith("/**")) docCommentContent = docCommentContent.substring(3); + if (docCommentContent.endsWith("*/")) docCommentContent = docCommentContent.substring(0, docCommentContent.length() -2); + docCommentContent = CONTENT_STRIPPER.matcher(docCommentContent).replaceAll("$1"); + docCommentContent = docCommentContent.trim(); + + if (Javac.getDocComments(top) == null) Javac.initDocComments(top); + + Object map_ = Javac.getDocComments(top); + if (map_ instanceof Map) { + ((Map) map_).put(node, docCommentContent); + return true; + } + + return false; + } + + private JCTree findJavadocableNodeOnOrAfter(JCCompilationUnit unit, int endPos) { + if (unit.pid != null && endPos <= unit.pid.pos) return null; + Iterator it = unit.defs.iterator(); + + while (it.hasNext()) { + JCTree node = it.next(); + if (node.pos < endPos) { + if (node instanceof JCClassDecl) { + com.sun.tools.javac.util.List defs = ((JCClassDecl) node).defs; + if (!defs.isEmpty()) while (!defs.tail.isEmpty()) defs = defs.tail; + if (defs.head != null && defs.head.pos >= endPos) { + // The associated node is IN this class declaration, so, replace the iterator. + // There's no point looking beyond this member in the current iteration 'context' + // so we don't need to save the old ref. Just start over inside this type declaration. + it = ((JCClassDecl) node).defs.iterator(); + } + } + continue; + } + + if (node instanceof JCMethodDecl || node instanceof JCClassDecl || node instanceof JCVariableDecl) return node; + return null; + } + + return null; + } +} diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 9978a681..525773f4 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -29,18 +29,14 @@ */ package lombok.delombok; -import static com.sun.tools.javac.code.Flags.ANNOTATION; -import static com.sun.tools.javac.code.Flags.ENUM; -import static com.sun.tools.javac.code.Flags.INTERFACE; -import static com.sun.tools.javac.code.Flags.SYNTHETIC; -import static com.sun.tools.javac.code.Flags.StandardFlags; -import static com.sun.tools.javac.code.Flags.VARARGS; +import static com.sun.tools.javac.code.Flags.*; +import static lombok.javac.Javac.*; +import static lombok.javac.JavacTreeMaker.TreeTag.treeTag; +import static lombok.javac.JavacTreeMaker.TypeTag.typeTag; import java.io.IOException; import java.io.Writer; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; @@ -49,19 +45,11 @@ import lombok.javac.CommentInfo.EndConnection; import lombok.javac.CommentInfo.StartConnection; import lombok.javac.JavacTreeMaker.TreeTag; import lombok.javac.JavacTreeMaker.TypeTag; -import static lombok.javac.Javac.*; -import static lombok.javac.JavacTreeMaker.TreeTag.treeTag; -import static lombok.javac.JavacTreeMaker.TypeTag.typeTag; import com.sun.source.tree.Tree; -import com.sun.tools.javac.code.BoundKind; import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.code.Symbol; -//import com.sun.tools.javac.code.TypeTags; -import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.tree.JCTree; -import com.sun.tools.javac.tree.TreeInfo; -import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCArrayAccess; import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; @@ -113,10 +101,13 @@ import com.sun.tools.javac.tree.JCTree.JCWhileLoop; import com.sun.tools.javac.tree.JCTree.JCWildcard; import com.sun.tools.javac.tree.JCTree.LetExpr; import com.sun.tools.javac.tree.JCTree.TypeBoundKind; +import com.sun.tools.javac.tree.TreeInfo; +import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.Convert; import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Position; +//import com.sun.tools.javac.code.TypeTags; /** Prints out a tree as an indented Java source program. * @@ -198,13 +189,7 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { boolean found = false; CommentInfo head = comments.head; while (comments.nonEmpty() && head.pos < until) { - if (tree != null && docComments != null && docComments.containsKey(tree) && head.isJavadoc() && noFurtherJavadocForthcoming(until)) { - // This is (presumably) the exact same javadoc that has already been associated with the node that we're just about to - // print. These javadoc can be modified by lombok handlers, and as such we should NOT print them from the consumed comments db, - // and instead print the actual javadoc associated with the upcoming node (which the visit method for that node will take care of). - } else { - printComment(head); - } + printComment(head); comments = comments.tail; head = comments.head; } @@ -213,17 +198,6 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { } } - private boolean noFurtherJavadocForthcoming(int until) { - List c = comments; - if (c.nonEmpty()) c = c.tail; - while (c.nonEmpty()) { - if (c.head.pos >= until) return true; - if (c.head.isJavadoc()) return false; - c = c.tail; - } - return true; - } - private void consumeTrailingComments(int from) throws IOException { boolean prevNewLine = onNewLine; CommentInfo head = comments.head; diff --git a/src/utils/lombok/javac/CommentCatcher.java b/src/utils/lombok/javac/CommentCatcher.java index 48dd7e75..36d90e30 100644 --- a/src/utils/lombok/javac/CommentCatcher.java +++ b/src/utils/lombok/javac/CommentCatcher.java @@ -22,13 +22,14 @@ package lombok.javac; import java.lang.reflect.InvocationTargetException; +import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.WeakHashMap; import com.sun.tools.javac.main.JavaCompiler; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.List; public class CommentCatcher { private final JavaCompiler compiler; @@ -56,9 +57,17 @@ public class CommentCatcher { return compiler; } + public void setComments(JCCompilationUnit ast, List comments) { + if (comments != null) { + commentsMap.put(ast, comments); + } else { + commentsMap.remove(ast); + } + } + public List getComments(JCCompilationUnit ast) { List list = commentsMap.get(ast); - return list == null ? List.nil() : list; + return list == null ? Collections.emptyList() : list; } private static void registerCommentsCollectingScannerFactory(Context context) { diff --git a/src/utils/lombok/javac/Javac.java b/src/utils/lombok/javac/Javac.java index c90b8611..2f3c9be4 100644 --- a/src/utils/lombok/javac/Javac.java +++ b/src/utils/lombok/javac/Javac.java @@ -27,6 +27,7 @@ import static lombok.javac.JavacTreeMaker.TypeTag.typeTag; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -196,6 +197,16 @@ public class Javac { } } + public static void initDocComments(JCCompilationUnit cu) { + try { + JCCOMPILATIONUNIT_DOCCOMMENTS.set(cu, new HashMap()); + } catch (IllegalArgumentException e) { + // That's fine - we're on JDK8, we'll fix that later. + } catch (IllegalAccessException e) { + throw sneakyThrow(e); + } + } + public static int getEndPosition(DiagnosticPosition pos, JCCompilationUnit top) { try { Object endPositions = JCCOMPILATIONUNIT_ENDPOSITIONS.get(top); diff --git a/test/transform/resource/after-delombok/GetterSetterJavadoc.java b/test/transform/resource/after-delombok/GetterSetterJavadoc.java index 7bf92d1f..af9cbb5e 100644 --- a/test/transform/resource/after-delombok/GetterSetterJavadoc.java +++ b/test/transform/resource/after-delombok/GetterSetterJavadoc.java @@ -9,7 +9,7 @@ class GetterSetterJavadoc1 { /** * Getter section * - * @return Sky is blue + * @return Sky is blue1 */ @java.lang.SuppressWarnings("all") public int getFieldName() { @@ -18,7 +18,7 @@ class GetterSetterJavadoc1 { /** * Some text * - * @param fieldName Hello, World + * @param fieldName Hello, World1 */ @java.lang.SuppressWarnings("all") public void setFieldName(final int fieldName) { @@ -60,7 +60,7 @@ class GetterSetterJavadoc2 { /** * Some text * - * @return Sky is blue + * @return Sky is blue2 */ @java.lang.SuppressWarnings("all") public int getFieldName() { @@ -69,7 +69,7 @@ class GetterSetterJavadoc2 { /** * Some text * - * @param fieldName Hello, World + * @param fieldName Hello, World2 */ @java.lang.SuppressWarnings("all") public void setFieldName(final int fieldName) { @@ -83,7 +83,7 @@ class GetterSetterJavadoc3 { private int fieldName; /** * Getter section - * @return Sky is blue + * @return Sky is blue3 */ @java.lang.SuppressWarnings("all") public int getFieldName() { @@ -91,7 +91,7 @@ class GetterSetterJavadoc3 { } /** * Setter section - * @param fieldName Hello, World + * @param fieldName Hello, World3 */ @java.lang.SuppressWarnings("all") public void setFieldName(final int fieldName) { diff --git a/test/transform/resource/before/GetterSetterJavadoc.java b/test/transform/resource/before/GetterSetterJavadoc.java index e3ae0aac..0dc64092 100644 --- a/test/transform/resource/before/GetterSetterJavadoc.java +++ b/test/transform/resource/before/GetterSetterJavadoc.java @@ -3,11 +3,11 @@ class GetterSetterJavadoc1 { /** * Some text * - * @param fieldName Hello, World + * @param fieldName Hello, World1 * --- GETTER --- * Getter section * - * @return Sky is blue + * @return Sky is blue1 */ private int fieldName; } @@ -16,8 +16,8 @@ class GetterSetterJavadoc2 { /** * Some text * - * @param fieldName Hello, World - * @return Sky is blue + * @param fieldName Hello, World2 + * @return Sky is blue2 */ @lombok.Getter @lombok.Setter private int fieldName; } @@ -28,10 +28,10 @@ class GetterSetterJavadoc3 { * * **SETTER** * Setter section - * @param fieldName Hello, World + * @param fieldName Hello, World3 * **GETTER** * Getter section - * @return Sky is blue + * @return Sky is blue3 */ @lombok.Getter @lombok.Setter private int fieldName; } -- cgit From 52d4c81a590f790de057653e7ffd091b6706ee34 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 9 Sep 2013 23:54:51 +0200 Subject: Updated unit tests to reflect new double-underscore default for onX. (Because single underscore generates warnings in javac8). --- .../messages-delombok/GetterOnMethodErrors2.java.messages | 8 ++++---- .../resource/messages-ecj/GetterOnMethodErrors2.java.messages | 8 ++++---- test/transform/resource/messages-ecj/ValInBasicFor.java.messages | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) (limited to 'test') diff --git a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages index af1e3b7a..53a9b9ad 100644 --- a/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-delombok/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -3 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -4 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -5 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +2 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +3 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +4 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +5 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) diff --git a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages index af1e3b7a..53a9b9ad 100644 --- a/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages +++ b/test/transform/resource/messages-ecj/GetterOnMethodErrors2.java.messages @@ -1,4 +1,4 @@ -2 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -3 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -4 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) -5 The correct format is @Getter(onMethod=@_({@SomeAnnotation, @SomeOtherAnnotation})) +2 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +3 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +4 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) +5 The correct format is @Getter(onMethod=@__({@SomeAnnotation, @SomeOtherAnnotation})) diff --git a/test/transform/resource/messages-ecj/ValInBasicFor.java.messages b/test/transform/resource/messages-ecj/ValInBasicFor.java.messages index 43cd7ce8..c75e20f2 100644 --- a/test/transform/resource/messages-ecj/ValInBasicFor.java.messages +++ b/test/transform/resource/messages-ecj/ValInBasicFor.java.messages @@ -1,4 +1,2 @@ 6 'val' is not allowed in old-style for loops 6 Type mismatch: cannot convert from int to val -6 'val' is not allowed in old-style for loops -6 'val' is not allowed in old-style for loops -- cgit From 72b55dccb18f38b8aefd0ac8e7c2e8bd2dd5c057 Mon Sep 17 00:00:00 2001 From: Sander Koning Date: Fri, 20 Sep 2013 17:13:39 +0200 Subject: Issue 559: NullPointerException when @NonNull is used in abstract method - Prevent NPE in javac and give a proper warning in both eclipse and javac - Add test cases --- src/core/lombok/eclipse/handlers/NonNullHandler.java | 5 +++++ src/core/lombok/javac/handlers/NonNullHandler.java | 5 +++++ .../resource/after-delombok/NonNullOnParameterAbstract.java | 10 ++++++++++ .../resource/after-ecj/NonNullOnParameterAbstract.java | 13 +++++++++++++ .../resource/before/NonNullOnParameterAbstract.java | 7 +++++++ .../NonNullOnParameterAbstract.java.messages | 1 + .../messages-ecj/NonNullOnParameterAbstract.java.messages | 1 + .../NonNullOnParameterAbstract.java.messages | 1 + 8 files changed, 43 insertions(+) create mode 100644 test/transform/resource/after-delombok/NonNullOnParameterAbstract.java create mode 100644 test/transform/resource/after-ecj/NonNullOnParameterAbstract.java create mode 100644 test/transform/resource/before/NonNullOnParameterAbstract.java create mode 100644 test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages create mode 100644 test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages create mode 100644 test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages (limited to 'test') diff --git a/src/core/lombok/eclipse/handlers/NonNullHandler.java b/src/core/lombok/eclipse/handlers/NonNullHandler.java index 5c58069c..59fda801 100644 --- a/src/core/lombok/eclipse/handlers/NonNullHandler.java +++ b/src/core/lombok/eclipse/handlers/NonNullHandler.java @@ -82,6 +82,11 @@ public class NonNullHandler extends EclipseAnnotationHandler { if (isGenerated(declaration)) return; + if (declaration.isAbstract()) { + annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); + return; + } + // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and // wrap all references to it in the super/this to a call to this method. diff --git a/src/core/lombok/javac/handlers/NonNullHandler.java b/src/core/lombok/javac/handlers/NonNullHandler.java index 415d6032..392e8390 100644 --- a/src/core/lombok/javac/handlers/NonNullHandler.java +++ b/src/core/lombok/javac/handlers/NonNullHandler.java @@ -76,6 +76,11 @@ public class NonNullHandler extends JavacAnnotationHandler { if (JavacHandlerUtil.isGenerated(declaration)) return; + if (declaration.body == null) { + annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); + return; + } + // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and // wrap all references to it in the super/this to a call to this method. diff --git a/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java new file mode 100644 index 00000000..e0330bd6 --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullOnParameterAbstract.java @@ -0,0 +1,10 @@ +abstract class NonNullOnParameterAbstract { + public void test(@lombok.NonNull String arg) { + if (arg == null) { + throw new java.lang.NullPointerException("arg"); + } + System.out.println("Hey"); + } + + public abstract void test2(@lombok.NonNull String arg); +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java new file mode 100644 index 00000000..a7dae247 --- /dev/null +++ b/test/transform/resource/after-ecj/NonNullOnParameterAbstract.java @@ -0,0 +1,13 @@ +abstract class NonNullOnParameterAbstract { + NonNullOnParameterAbstract() { + super(); + } + public void test(@lombok.NonNull String arg) { + if ((arg == null)) + { + throw new java.lang.NullPointerException("arg"); + } + System.out.println("Hey"); + } + public abstract void test2(@lombok.NonNull String arg); +} \ No newline at end of file diff --git a/test/transform/resource/before/NonNullOnParameterAbstract.java b/test/transform/resource/before/NonNullOnParameterAbstract.java new file mode 100644 index 00000000..16691184 --- /dev/null +++ b/test/transform/resource/before/NonNullOnParameterAbstract.java @@ -0,0 +1,7 @@ +abstract class NonNullOnParameterAbstract { + public void test(@lombok.NonNull String arg) { + System.out.println("Hey"); + } + + public abstract void test2(@lombok.NonNull String arg); +} \ No newline at end of file diff --git a/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages new file mode 100644 index 00000000..1ebeea05 --- /dev/null +++ b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages @@ -0,0 +1 @@ +6:36 @NonNull is meaningless on a parameter of an abstract method. diff --git a/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages new file mode 100644 index 00000000..48d1508e --- /dev/null +++ b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages @@ -0,0 +1 @@ +6:154 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file diff --git a/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages new file mode 100644 index 00000000..00547171 --- /dev/null +++ b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages @@ -0,0 +1 @@ +9:36 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file -- cgit From 7b8a85e1f991f838d6692ef789f53ed604a4a4e9 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 24 Sep 2013 01:33:22 +0200 Subject: Fixed slight typo issues with the tests due to merging and icelandic on the fly bug fixing. --- .../EqualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- .../messages-delombok/NonNullOnParameterAbstract.java.messages | 2 +- .../EqualsAndHashCodeWithSomeExistingMethods.java.messages | 4 ++-- .../resource/messages-ecj/NonNullOnParameterAbstract.java.messages | 2 +- .../messages-idempotent/NonNullOnParameterAbstract.java.messages | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages index f5dfd559..75ddfa54 100644 --- a/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-delombok/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). +15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). diff --git a/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages index 1ebeea05..fd5bffd5 100644 --- a/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages +++ b/test/transform/resource/messages-delombok/NonNullOnParameterAbstract.java.messages @@ -1 +1 @@ -6:36 @NonNull is meaningless on a parameter of an abstract method. +6 @NonNull is meaningless on a parameter of an abstract method. diff --git a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages index f5dfd559..75ddfa54 100644 --- a/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages +++ b/test/transform/resource/messages-ecj/EqualsAndHashCodeWithSomeExistingMethods.java.messages @@ -1,2 +1,2 @@ -4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). -15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these are none of these (in the latter case, lombok generates them). +4 Not generating equals: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). +15 Not generating equals and hashCode: One of equals, hashCode, and canEqual exists. You should either write all of these or none of these (in the latter case, lombok generates them). diff --git a/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages index 48d1508e..8eb312ef 100644 --- a/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages +++ b/test/transform/resource/messages-ecj/NonNullOnParameterAbstract.java.messages @@ -1 +1 @@ -6:154 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file +6 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file diff --git a/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages index 00547171..0d9fcfdc 100644 --- a/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages +++ b/test/transform/resource/messages-idempotent/NonNullOnParameterAbstract.java.messages @@ -1 +1 @@ -9:36 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file +9 @NonNull is meaningless on a parameter of an abstract method. \ No newline at end of file -- cgit From a9b4fb0c685fbc52079d57532c04277e78c95ec2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 10 Oct 2013 22:36:16 +0200 Subject: Fix for issues when mixing @NonNull on params with @SneakyThrows or @Synchronized [Issue #588] --- doc/changelog.markdown | 9 +- src/core/lombok/core/Version.java | 2 +- .../lombok/eclipse/handlers/HandleNonNull.java | 175 ++++++++++++++++++++ .../eclipse/handlers/HandleSneakyThrows.java | 2 + .../eclipse/handlers/HandleSynchronized.java | 2 + .../lombok/eclipse/handlers/NonNullHandler.java | 152 ----------------- src/core/lombok/javac/handlers/HandleNonNull.java | 179 +++++++++++++++++++++ .../lombok/javac/handlers/HandleSneakyThrows.java | 2 + .../lombok/javac/handlers/HandleSynchronized.java | 2 + src/core/lombok/javac/handlers/NonNullHandler.java | 156 ------------------ .../after-delombok/NonNullWithSneakyThrows.java | 12 ++ test/transform/resource/after-ecj/InjectField.java | 4 +- .../after-ecj/NonNullWithSneakyThrows.java | 18 +++ .../resource/before/NonNullWithSneakyThrows.java | 5 + 14 files changed, 407 insertions(+), 313 deletions(-) create mode 100644 src/core/lombok/eclipse/handlers/HandleNonNull.java delete mode 100644 src/core/lombok/eclipse/handlers/NonNullHandler.java create mode 100644 src/core/lombok/javac/handlers/HandleNonNull.java delete mode 100644 src/core/lombok/javac/handlers/NonNullHandler.java create mode 100644 test/transform/resource/after-delombok/NonNullWithSneakyThrows.java create mode 100644 test/transform/resource/after-ecj/NonNullWithSneakyThrows.java create mode 100644 test/transform/resource/before/NonNullWithSneakyThrows.java (limited to 'test') diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 7782f1fa..1ee3504c 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -1,8 +1,13 @@ Lombok Changelog ---------------- -### v0.12.1 "Edgy Guinea Pig" -* PLATFORM: Initial (not quite totally finished) JDK8 support, without affecting existing support for JDK6 and 7. [Issue #451](https://code.google.com/p/projectlombok/issues/detail?id=451). +### v1.12.2 (October 10th, 2013) +* PLATFORM: Initial JDK8 support, without affecting existing support for JDK6 and 7. [Issue #451](https://code.google.com/p/projectlombok/issues/detail?id=451). While lombok will now work on JDK8 / javac8, and netbeans 7.4 and up, lombok does not (yet) support new language features introduced with java8, such as lambda expressions. Support for these features will be added in a future version. +* PLATFORM: Running javac on IBM J9 VM would cause NullPointerExceptions when compiling with lombok. These issues should be fixed. [Issue #554](https://code.google.com/p/projectlombok/issues/detail?id=554). +* CHANGE: [JDK8-related] The canonical way to write onMethod / onParameter / onConstructor annotation now uses a double underscore instead of a single underscore, so, now, the proper way to use this feature is `@RequiredArgsConstructor(onConstructor=@__(@Inject))`. The old way (single underscore) still works, but generates warnings on javac 8. +* BUGFIX: Using `@NonNull` on an abstract method used to cause exceptions during compilation. [Issue #559](https://code.google.com/p/projectlombok/issues/detail?id=559). +* BUGFIX: Using `@NonNull` on methods that also have `@SneakyThrows` or `@Synchronized` caused arbitrary behaviour. [Issue #588](https://code.google.com/p/projectlombok/issues/detail?id=588). +* GERMANY: Major version bumped from 0 to 1, because allegedly this is important. Rest assured, this change is nevertheless backwards compatible. ### v0.12.0 "Angry Butterfly" (July 16th, 2013) * FEATURE: javadoc on fields will now be copied to generated getters / setters / withers. There are ways to specify separate javadoc for the field, the setter, and the getter, and `@param` and `@return` are handled appropriately. Addresses feature request [Issue #59](https://code.google.com/p/projectlombok/issues/detail?id=59). [@Getter and @Setter documentation](http://projectlombok.org/features/GetterSetter.html). [@Wither documentation](http://projectlombok.org/features/experimental/Wither.html). diff --git a/src/core/lombok/core/Version.java b/src/core/lombok/core/Version.java index 24faf821..318075d3 100644 --- a/src/core/lombok/core/Version.java +++ b/src/core/lombok/core/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2011 The Project Lombok Authors. + * Copyright (C) 2009-2013 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/core/lombok/eclipse/handlers/HandleNonNull.java b/src/core/lombok/eclipse/handlers/HandleNonNull.java new file mode 100644 index 00000000..634cb2d9 --- /dev/null +++ b/src/core/lombok/eclipse/handlers/HandleNonNull.java @@ -0,0 +1,175 @@ +/* + * Copyright (C) 2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.eclipse.handlers; + +import static lombok.eclipse.Eclipse.isPrimitive; +import static lombok.eclipse.handlers.EclipseHandlerUtil.*; + +import java.util.Arrays; + +import lombok.NonNull; +import lombok.core.AST.Kind; +import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; +import lombok.eclipse.DeferUntilPostDiet; +import lombok.eclipse.EclipseAnnotationHandler; +import lombok.eclipse.EclipseNode; + +import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; +import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; +import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.Argument; +import org.eclipse.jdt.internal.compiler.ast.Block; +import org.eclipse.jdt.internal.compiler.ast.EqualExpression; +import org.eclipse.jdt.internal.compiler.ast.Expression; +import org.eclipse.jdt.internal.compiler.ast.IfStatement; +import org.eclipse.jdt.internal.compiler.ast.NullLiteral; +import org.eclipse.jdt.internal.compiler.ast.OperatorIds; +import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; +import org.eclipse.jdt.internal.compiler.ast.Statement; +import org.eclipse.jdt.internal.compiler.ast.SynchronizedStatement; +import org.eclipse.jdt.internal.compiler.ast.ThrowStatement; +import org.eclipse.jdt.internal.compiler.ast.TryStatement; +import org.mangosdk.spi.ProviderFor; + +@DeferUntilPostDiet +@ProviderFor(EclipseAnnotationHandler.class) +@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first. +public class HandleNonNull extends EclipseAnnotationHandler { + @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { + if (annotationNode.up().getKind() == Kind.FIELD) { + // This is meaningless unless the field is used to generate a method (@Setter, @RequiredArgsConstructor, etc), + // but in that case those handlers will take care of it. However, we DO check if the annotation is applied to + // a primitive, because those handlers trigger on any annotation named @NonNull and we only want the warning + // behaviour on _OUR_ 'lombok.NonNull'. + + try { + if (isPrimitive(((AbstractVariableDeclaration) annotationNode.up().get()).type)) { + annotationNode.addWarning("@NonNull is meaningless on a primitive."); + } + } catch (Exception ignore) {} + + return; + } + + if (annotationNode.up().getKind() != Kind.ARGUMENT) return; + + Argument arg; + AbstractMethodDeclaration declaration; + + try { + arg = (Argument) annotationNode.up().get(); + declaration = (AbstractMethodDeclaration) annotationNode.up().up().get(); + } catch (Exception e) { + return; + } + + if (isGenerated(declaration)) return; + + if (declaration.isAbstract()) { + annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); + return; + } + + // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, + // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and + // wrap all references to it in the super/this to a call to this method. + + Statement nullCheck = generateNullCheck(arg, ast); + + if (nullCheck == null) { + // @NonNull applied to a primitive. Kinda pointless. Let's generate a warning. + annotationNode.addWarning("@NonNull is meaningless on a primitive."); + return; + } + + if (declaration.statements == null) { + declaration.statements = new Statement[] {nullCheck}; + } else { + char[] expectedName = arg.name; + /* Abort if the null check is already there, delving into try and synchronized statements */ { + Statement[] stats = declaration.statements; + int idx = 0; + while (stats != null && stats.length > idx) { + Statement stat = stats[idx++]; + if (stat instanceof TryStatement) { + stats = ((TryStatement) stat).tryBlock.statements; + idx = 0; + continue; + } + if (stat instanceof SynchronizedStatement) { + stats = ((SynchronizedStatement) stat).block.statements; + idx = 0; + continue; + } + char[] varNameOfNullCheck = returnVarNameIfNullCheck(stat); + if (varNameOfNullCheck == null) break; + if (Arrays.equals(varNameOfNullCheck, expectedName)) return; + } + } + + Statement[] newStatements = new Statement[declaration.statements.length + 1]; + int skipOver = 0; + for (Statement stat : declaration.statements) { + if (isGenerated(stat) && isNullCheck(stat)) skipOver++; + else break; + } + System.arraycopy(declaration.statements, 0, newStatements, 0, skipOver); + System.arraycopy(declaration.statements, skipOver, newStatements, skipOver + 1, declaration.statements.length - skipOver); + newStatements[skipOver] = nullCheck; + declaration.statements = newStatements; + } + annotationNode.up().up().rebuild(); + } + + private boolean isNullCheck(Statement stat) { + return returnVarNameIfNullCheck(stat) != null; + } + + private char[] returnVarNameIfNullCheck(Statement stat) { + if (!(stat instanceof IfStatement)) return null; + + /* Check that the if's statement is a throw statement, possibly in a block. */ { + Statement then = ((IfStatement) stat).thenStatement; + if (then instanceof Block) { + Statement[] blockStatements = ((Block) then).statements; + if (blockStatements == null || blockStatements.length == 0) return null; + then = blockStatements[0]; + } + + if (!(then instanceof ThrowStatement)) return null; + } + + /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate + a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { + Expression cond = ((IfStatement) stat).condition; + if (!(cond instanceof EqualExpression)) return null; + EqualExpression bin = (EqualExpression) cond; + int operatorId = ((bin.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT); + if (operatorId != OperatorIds.EQUAL_EQUAL) return null; + if (!(bin.left instanceof SingleNameReference)) return null; + if (!(bin.right instanceof NullLiteral)) return null; + return ((SingleNameReference) bin.left).token; + } + } +} diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java index aa78ca3b..d3a95db8 100644 --- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java @@ -30,6 +30,7 @@ import java.util.List; import lombok.SneakyThrows; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.eclipse.DeferUntilPostDiet; import lombok.eclipse.EclipseAnnotationHandler; import lombok.eclipse.EclipseNode; @@ -60,6 +61,7 @@ import org.mangosdk.spi.ProviderFor; */ @ProviderFor(EclipseAnnotationHandler.class) @DeferUntilPostDiet +@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it. public class HandleSneakyThrows extends EclipseAnnotationHandler { private static class DeclaredException { diff --git a/src/core/lombok/eclipse/handlers/HandleSynchronized.java b/src/core/lombok/eclipse/handlers/HandleSynchronized.java index e4c58eab..f76f06ed 100644 --- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java +++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java @@ -27,6 +27,7 @@ import java.lang.reflect.Modifier; import lombok.Synchronized; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.core.AST.Kind; import lombok.eclipse.DeferUntilPostDiet; import lombok.eclipse.EclipseAnnotationHandler; @@ -52,6 +53,7 @@ import org.mangosdk.spi.ProviderFor; */ @ProviderFor(EclipseAnnotationHandler.class) @DeferUntilPostDiet +@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it. public class HandleSynchronized extends EclipseAnnotationHandler { private static final char[] INSTANCE_LOCK_NAME = "$lock".toCharArray(); private static final char[] STATIC_LOCK_NAME = "$LOCK".toCharArray(); diff --git a/src/core/lombok/eclipse/handlers/NonNullHandler.java b/src/core/lombok/eclipse/handlers/NonNullHandler.java deleted file mode 100644 index 59fda801..00000000 --- a/src/core/lombok/eclipse/handlers/NonNullHandler.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (C) 2013 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.eclipse.handlers; - -import java.util.Arrays; - -import org.eclipse.jdt.internal.compiler.ast.ASTNode; -import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; -import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration; -import org.eclipse.jdt.internal.compiler.ast.Annotation; -import org.eclipse.jdt.internal.compiler.ast.Argument; -import org.eclipse.jdt.internal.compiler.ast.Block; -import org.eclipse.jdt.internal.compiler.ast.EqualExpression; -import org.eclipse.jdt.internal.compiler.ast.Expression; -import org.eclipse.jdt.internal.compiler.ast.IfStatement; -import org.eclipse.jdt.internal.compiler.ast.NullLiteral; -import org.eclipse.jdt.internal.compiler.ast.OperatorIds; -import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; -import org.eclipse.jdt.internal.compiler.ast.Statement; -import org.eclipse.jdt.internal.compiler.ast.ThrowStatement; -import org.mangosdk.spi.ProviderFor; - -import lombok.NonNull; -import lombok.core.AST.Kind; -import lombok.core.AnnotationValues; -import lombok.eclipse.DeferUntilPostDiet; -import lombok.eclipse.EclipseAnnotationHandler; -import lombok.eclipse.EclipseNode; - -import static lombok.eclipse.Eclipse.*; -import static lombok.eclipse.handlers.EclipseHandlerUtil.*; - -@DeferUntilPostDiet -@ProviderFor(EclipseAnnotationHandler.class) -public class NonNullHandler extends EclipseAnnotationHandler { - @Override public void handle(AnnotationValues annotation, Annotation ast, EclipseNode annotationNode) { - if (annotationNode.up().getKind() == Kind.FIELD) { - // This is meaningless unless the field is used to generate a method (@Setter, @RequiredArgsConstructor, etc), - // but in that case those handlers will take care of it. However, we DO check if the annotation is applied to - // a primitive, because those handlers trigger on any annotation named @NonNull and we only want the warning - // behaviour on _OUR_ 'lombok.NonNull'. - - try { - if (isPrimitive(((AbstractVariableDeclaration) annotationNode.up().get()).type)) { - annotationNode.addWarning("@NonNull is meaningless on a primitive."); - } - } catch (Exception ignore) {} - - return; - } - - if (annotationNode.up().getKind() != Kind.ARGUMENT) return; - - Argument arg; - AbstractMethodDeclaration declaration; - - try { - arg = (Argument) annotationNode.up().get(); - declaration = (AbstractMethodDeclaration) annotationNode.up().up().get(); - } catch (Exception e) { - return; - } - - if (isGenerated(declaration)) return; - - if (declaration.isAbstract()) { - annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); - return; - } - - // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, - // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and - // wrap all references to it in the super/this to a call to this method. - - Statement nullCheck = generateNullCheck(arg, ast); - - if (nullCheck == null) { - // @NonNull applied to a primitive. Kinda pointless. Let's generate a warning. - annotationNode.addWarning("@NonNull is meaningless on a primitive."); - return; - } - - if (declaration.statements == null) { - declaration.statements = new Statement[] {nullCheck}; - } else { - char[] expectedName = arg.name; - for (Statement stat : declaration.statements) { - char[] varNameOfNullCheck = returnVarNameIfNullCheck(stat); - if (varNameOfNullCheck == null) break; - if (Arrays.equals(expectedName, varNameOfNullCheck)) return; - } - - Statement[] newStatements = new Statement[declaration.statements.length + 1]; - int skipOver = 0; - for (Statement stat : declaration.statements) { - if (isGenerated(stat)) skipOver++; - else break; - } - System.arraycopy(declaration.statements, 0, newStatements, 0, skipOver); - System.arraycopy(declaration.statements, skipOver, newStatements, skipOver + 1, declaration.statements.length - skipOver); - newStatements[skipOver] = nullCheck; - declaration.statements = newStatements; - } - annotationNode.up().up().rebuild(); - } - - private char[] returnVarNameIfNullCheck(Statement stat) { - if (!(stat instanceof IfStatement)) return null; - - /* Check that the if's statement is a throw statement, possibly in a block. */ { - Statement then = ((IfStatement) stat).thenStatement; - if (then instanceof Block) { - Statement[] blockStatements = ((Block) then).statements; - if (blockStatements == null || blockStatements.length == 0) return null; - then = blockStatements[0]; - } - - if (!(then instanceof ThrowStatement)) return null; - } - - /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate - a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { - Expression cond = ((IfStatement) stat).condition; - if (!(cond instanceof EqualExpression)) return null; - EqualExpression bin = (EqualExpression) cond; - int operatorId = ((bin.bits & ASTNode.OperatorMASK) >> ASTNode.OperatorSHIFT); - if (operatorId != OperatorIds.EQUAL_EQUAL) return null; - if (!(bin.left instanceof SingleNameReference)) return null; - if (!(bin.right instanceof NullLiteral)) return null; - return ((SingleNameReference) bin.left).token; - } - } -} diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java new file mode 100644 index 00000000..21611a39 --- /dev/null +++ b/src/core/lombok/javac/handlers/HandleNonNull.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2013 The Project Lombok Authors. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.javac.handlers; + +import static lombok.javac.Javac.*; +import static lombok.javac.handlers.JavacHandlerUtil.*; + +import org.mangosdk.spi.ProviderFor; + +import com.sun.tools.javac.tree.JCTree.JCAnnotation; +import com.sun.tools.javac.tree.JCTree.JCBinary; +import com.sun.tools.javac.tree.JCTree.JCBlock; +import com.sun.tools.javac.tree.JCTree.JCExpression; +import com.sun.tools.javac.tree.JCTree.JCIdent; +import com.sun.tools.javac.tree.JCTree.JCIf; +import com.sun.tools.javac.tree.JCTree.JCLiteral; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; +import com.sun.tools.javac.tree.JCTree.JCParens; +import com.sun.tools.javac.tree.JCTree.JCStatement; +import com.sun.tools.javac.tree.JCTree.JCSynchronized; +import com.sun.tools.javac.tree.JCTree.JCThrow; +import com.sun.tools.javac.tree.JCTree.JCTry; +import com.sun.tools.javac.tree.JCTree.JCVariableDecl; +import com.sun.tools.javac.util.List; + +import lombok.NonNull; +import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; +import lombok.core.AST.Kind; +import lombok.javac.JavacAnnotationHandler; +import lombok.javac.JavacNode; +import static lombok.javac.JavacTreeMaker.TypeTag.*; +import static lombok.javac.JavacTreeMaker.TreeTag.*; + +@ProviderFor(JavacAnnotationHandler.class) +@HandlerPriority(value = 512) // 2^9; onParameter=@__(@NonNull) has to run first. +public class HandleNonNull extends JavacAnnotationHandler { + @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { + if (annotationNode.up().getKind() == Kind.FIELD) { + // This is meaningless unless the field is used to generate a method (@Setter, @RequiredArgsConstructor, etc), + // but in that case those handlers will take care of it. However, we DO check if the annotation is applied to + // a primitive, because those handlers trigger on any annotation named @NonNull and we only want the warning + // behaviour on _OUR_ 'lombok.NonNull'. + + try { + if (isPrimitive(((JCVariableDecl) annotationNode.up().get()).vartype)) { + annotationNode.addWarning("@NonNull is meaningless on a primitive."); + } + } catch (Exception ignore) {} + + return; + } + + if (annotationNode.up().getKind() != Kind.ARGUMENT) return; + + JCMethodDecl declaration; + + try { + declaration = (JCMethodDecl) annotationNode.up().up().get(); + } catch (Exception e) { + return; + } + +// if (JavacHandlerUtil.isGenerated(declaration)) return; + + if (declaration.body == null) { + annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); + return; + } + + // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, + // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and + // wrap all references to it in the super/this to a call to this method. + + JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), annotationNode.up()), ast); + + if (nullCheck == null) { + // @NonNull applied to a primitive. Kinda pointless. Let's generate a warning. + annotationNode.addWarning("@NonNull is meaningless on a primitive."); + return; + } + + List statements = declaration.body.stats; + + String expectedName = annotationNode.up().getName(); + + /* Abort if the null check is already there, delving into try and synchronized statements */ { + List stats = statements; + int idx = 0; + while (stats.size() > idx) { + JCStatement stat = stats.get(idx++); + if (JavacHandlerUtil.isConstructorCall(stat)) continue; + if (stat instanceof JCTry) { + stats = ((JCTry) stat).body.stats; + idx = 0; + continue; + } + if (stat instanceof JCSynchronized) { + stats = ((JCSynchronized) stat).body.stats; + idx = 0; + continue; + } + String varNameOfNullCheck = returnVarNameIfNullCheck(stat); + if (varNameOfNullCheck == null) break; + if (varNameOfNullCheck.equals(expectedName)) return; + } + } + + List tail = statements; + List head = List.nil(); + for (JCStatement stat : statements) { + if (JavacHandlerUtil.isConstructorCall(stat) || (JavacHandlerUtil.isGenerated(stat) && isNullCheck(stat))) { + tail = tail.tail; + head = head.prepend(stat); + continue; + } + break; + } + + List newList = tail.prepend(nullCheck); + for (JCStatement stat : head) newList = newList.prepend(stat); + declaration.body.stats = newList; + } + + private boolean isNullCheck(JCStatement stat) { + return returnVarNameIfNullCheck(stat) != null; + } + + /** + * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;}, + * where the block braces are optional. If it is of this form, returns "x". + * If it is not of this form, returns null. + */ + private String returnVarNameIfNullCheck(JCStatement stat) { + if (!(stat instanceof JCIf)) return null; + + /* Check that the if's statement is a throw statement, possibly in a block. */ { + JCStatement then = ((JCIf) stat).thenpart; + if (then instanceof JCBlock) { + List stats = ((JCBlock) then).stats; + if (stats.length() == 0) return null; + then = stats.get(0); + } + if (!(then instanceof JCThrow)) return null; + } + + /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate + a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { + JCExpression cond = ((JCIf) stat).cond; + while (cond instanceof JCParens) cond = ((JCParens) cond).expr; + if (!(cond instanceof JCBinary)) return null; + JCBinary bin = (JCBinary) cond; + if (!CTC_EQUAL.equals(treeTag(bin))) return null; + if (!(bin.lhs instanceof JCIdent)) return null; + if (!(bin.rhs instanceof JCLiteral)) return null; + if (!CTC_BOT.equals(typeTag(bin.rhs))) return null; + return ((JCIdent) bin.lhs).name.toString(); + } + } +} diff --git a/src/core/lombok/javac/handlers/HandleSneakyThrows.java b/src/core/lombok/javac/handlers/HandleSneakyThrows.java index 69d2b45d..b41277c3 100644 --- a/src/core/lombok/javac/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/javac/handlers/HandleSneakyThrows.java @@ -29,6 +29,7 @@ import java.util.Collections; import lombok.SneakyThrows; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -49,6 +50,7 @@ import com.sun.tools.javac.util.List; * Handles the {@code lombok.SneakyThrows} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) +@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it. public class HandleSneakyThrows extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { deleteAnnotationIfNeccessary(annotationNode, SneakyThrows.class); diff --git a/src/core/lombok/javac/handlers/HandleSynchronized.java b/src/core/lombok/javac/handlers/HandleSynchronized.java index b173f8fb..661a7c2a 100644 --- a/src/core/lombok/javac/handlers/HandleSynchronized.java +++ b/src/core/lombok/javac/handlers/HandleSynchronized.java @@ -26,6 +26,7 @@ import static lombok.javac.handlers.JavacHandlerUtil.*; import lombok.Synchronized; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; +import lombok.core.HandlerPriority; import lombok.javac.JavacAnnotationHandler; import lombok.javac.JavacNode; import lombok.javac.JavacTreeMaker; @@ -46,6 +47,7 @@ import com.sun.tools.javac.util.List; * Handles the {@code lombok.Synchronized} annotation for javac. */ @ProviderFor(JavacAnnotationHandler.class) +@HandlerPriority(value = 1024) // 2^10; @NonNull must have run first, so that we wrap around the statements generated by it. public class HandleSynchronized extends JavacAnnotationHandler { private static final String INSTANCE_LOCK_NAME = "$lock"; private static final String STATIC_LOCK_NAME = "$LOCK"; diff --git a/src/core/lombok/javac/handlers/NonNullHandler.java b/src/core/lombok/javac/handlers/NonNullHandler.java deleted file mode 100644 index acf1588e..00000000 --- a/src/core/lombok/javac/handlers/NonNullHandler.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright (C) 2013 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.javac.handlers; - -import static lombok.javac.Javac.*; -import static lombok.javac.handlers.JavacHandlerUtil.*; - -import org.mangosdk.spi.ProviderFor; - -import com.sun.tools.javac.tree.JCTree.JCAnnotation; -import com.sun.tools.javac.tree.JCTree.JCBinary; -import com.sun.tools.javac.tree.JCTree.JCBlock; -import com.sun.tools.javac.tree.JCTree.JCExpression; -import com.sun.tools.javac.tree.JCTree.JCIdent; -import com.sun.tools.javac.tree.JCTree.JCIf; -import com.sun.tools.javac.tree.JCTree.JCLiteral; -import com.sun.tools.javac.tree.JCTree.JCMethodDecl; -import com.sun.tools.javac.tree.JCTree.JCParens; -import com.sun.tools.javac.tree.JCTree.JCStatement; -import com.sun.tools.javac.tree.JCTree.JCThrow; -import com.sun.tools.javac.tree.JCTree.JCVariableDecl; -import com.sun.tools.javac.util.List; - -import lombok.NonNull; -import lombok.core.AnnotationValues; -import lombok.core.AST.Kind; -import lombok.javac.JavacAnnotationHandler; -import lombok.javac.JavacNode; - -import static lombok.javac.JavacTreeMaker.TypeTag.*; -import static lombok.javac.JavacTreeMaker.TreeTag.*; - -@ProviderFor(JavacAnnotationHandler.class) -public class NonNullHandler extends JavacAnnotationHandler { - @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { - if (annotationNode.up().getKind() == Kind.FIELD) { - // This is meaningless unless the field is used to generate a method (@Setter, @RequiredArgsConstructor, etc), - // but in that case those handlers will take care of it. However, we DO check if the annotation is applied to - // a primitive, because those handlers trigger on any annotation named @NonNull and we only want the warning - // behaviour on _OUR_ 'lombok.NonNull'. - - try { - if (isPrimitive(((JCVariableDecl) annotationNode.up().get()).vartype)) { - annotationNode.addWarning("@NonNull is meaningless on a primitive."); - } - } catch (Exception ignore) {} - - return; - } - - if (annotationNode.up().getKind() != Kind.ARGUMENT) return; - - JCMethodDecl declaration; - - try { - declaration = (JCMethodDecl) annotationNode.up().up().get(); - } catch (Exception e) { - return; - } - - if (JavacHandlerUtil.isGenerated(declaration)) return; - - if (declaration.body == null) { - annotationNode.addWarning("@NonNull is meaningless on a parameter of an abstract method."); - return; - } - - // Possibly, if 'declaration instanceof ConstructorDeclaration', fetch declaration.constructorCall, search it for any references to our parameter, - // and if they exist, create a new method in the class: 'private static T lombok$nullCheck(T expr, String msg) {if (expr == null) throw NPE; return expr;}' and - // wrap all references to it in the super/this to a call to this method. - - JCStatement nullCheck = recursiveSetGeneratedBy(generateNullCheck(annotationNode.getTreeMaker(), annotationNode.up()), ast); - - if (nullCheck == null) { - // @NonNull applied to a primitive. Kinda pointless. Let's generate a warning. - annotationNode.addWarning("@NonNull is meaningless on a primitive."); - return; - } - - List statements = declaration.body.stats; - - String expectedName = annotationNode.up().getName(); - for (JCStatement stat : statements) { - if (JavacHandlerUtil.isConstructorCall(stat)) continue; - String varNameOfNullCheck = returnVarNameIfNullCheck(stat); - if (varNameOfNullCheck == null) break; - if (varNameOfNullCheck.equals(expectedName)) return; - } - - List tail = statements; - List head = List.nil(); - for (JCStatement stat : statements) { - if (JavacHandlerUtil.isConstructorCall(stat) || JavacHandlerUtil.isGenerated(stat)) { - tail = tail.tail; - head = head.prepend(stat); - continue; - } - break; - } - - List newList = tail.prepend(nullCheck); - for (JCStatement stat : head) newList = newList.prepend(stat); - declaration.body.stats = newList; - } - - /** - * Checks if the statement is of the form 'if (x == null) {throw WHATEVER;}, - * where the block braces are optional. If it is of this form, returns "x". - * If it is not of this form, returns null. - */ - private String returnVarNameIfNullCheck(JCStatement stat) { - if (!(stat instanceof JCIf)) return null; - - /* Check that the if's statement is a throw statement, possibly in a block. */ { - JCStatement then = ((JCIf) stat).thenpart; - if (then instanceof JCBlock) { - List stats = ((JCBlock) then).stats; - if (stats.length() == 0) return null; - then = stats.get(0); - } - if (!(then instanceof JCThrow)) return null; - } - - /* Check that the if's conditional is like 'x == null'. Return from this method (don't generate - a nullcheck) if 'x' is equal to our own variable's name: There's already a nullcheck here. */ { - JCExpression cond = ((JCIf) stat).cond; - while (cond instanceof JCParens) cond = ((JCParens) cond).expr; - if (!(cond instanceof JCBinary)) return null; - JCBinary bin = (JCBinary) cond; - if (!CTC_EQUAL.equals(treeTag(bin))) return null; - if (!(bin.lhs instanceof JCIdent)) return null; - if (!(bin.rhs instanceof JCLiteral)) return null; - if (!CTC_BOT.equals(typeTag(bin.rhs))) return null; - return ((JCIdent) bin.lhs).name.toString(); - } - } -} diff --git a/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java new file mode 100644 index 00000000..91646468 --- /dev/null +++ b/test/transform/resource/after-delombok/NonNullWithSneakyThrows.java @@ -0,0 +1,12 @@ +class NonNullWithSneakyThrows { + void test(@lombok.NonNull String in) { + try { + if (in == null) { + throw new java.lang.NullPointerException("in"); + } + System.out.println(in); + } catch (final java.lang.Throwable $ex) { + throw lombok.Lombok.sneakyThrow($ex); + } + } +} \ No newline at end of file diff --git a/test/transform/resource/after-ecj/InjectField.java b/test/transform/resource/after-ecj/InjectField.java index 83d9e5fa..f9ea9142 100644 --- a/test/transform/resource/after-ecj/InjectField.java +++ b/test/transform/resource/after-ecj/InjectField.java @@ -4,9 +4,9 @@ import lombok.Synchronized; @Log enum InjectField1 { A(), B(), + private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField1.class.getName()); private final java.lang.Object $lock = new java.lang.Object[0]; private static final java.lang.Object $LOCK = new java.lang.Object[0]; - private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField1.class.getName()); private static final String LOG_MESSAGE = "static initializer"; private String fieldA; static { @@ -32,8 +32,8 @@ import lombok.Synchronized; } } @Log class InjectField2 { - private final java.lang.Object $lock = new java.lang.Object[0]; private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(InjectField2.class.getName()); + private final java.lang.Object $lock = new java.lang.Object[0]; private static final String LOG_MESSAGE = "static initializer"; static { log.log(Level.FINE, LOG_MESSAGE); diff --git a/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java new file mode 100644 index 00000000..fac8dcdd --- /dev/null +++ b/test/transform/resource/after-ecj/NonNullWithSneakyThrows.java @@ -0,0 +1,18 @@ +class NonNullWithSneakyThrows { + NonNullWithSneakyThrows() { + super(); + } + @lombok.SneakyThrows void test(@lombok.NonNull String in) { + try + { + if ((in == null)) + { + throw new java.lang.NullPointerException("in"); + } + System.out.println(in); + } + catch (final java.lang.Throwable $ex) { + throw lombok.Lombok.sneakyThrow($ex); + } + } +} \ No newline at end of file diff --git a/test/transform/resource/before/NonNullWithSneakyThrows.java b/test/transform/resource/before/NonNullWithSneakyThrows.java new file mode 100644 index 00000000..35f78a7f --- /dev/null +++ b/test/transform/resource/before/NonNullWithSneakyThrows.java @@ -0,0 +1,5 @@ +class NonNullWithSneakyThrows { + @lombok.SneakyThrows void test(@lombok.NonNull String in) { + System.out.println(in); + } +} -- cgit From 5cdb0757d39d100c76bbca63734fb83b4cb13753 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 27 Oct 2013 22:32:44 +0100 Subject: [issue 598] JDK8 update broke assignment-with-operator in delombok. --- .../lombok/delombok/PrettyCommentsPrinter.java | 16 ++++++- .../resource/after-delombok/TestOperators.java | 48 ++++++++++++++++++++ .../resource/after-ecj/TestOperators.java | 51 ++++++++++++++++++++++ test/transform/resource/before/TestOperators.java | 48 ++++++++++++++++++++ website/features/experimental/index.html | 2 +- 5 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 test/transform/resource/after-delombok/TestOperators.java create mode 100644 test/transform/resource/after-ecj/TestOperators.java create mode 100644 test/transform/resource/before/TestOperators.java (limited to 'test') diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java index 67c313ab..f9152e68 100644 --- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java +++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java @@ -158,6 +158,18 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { map.put(treeTag("DIV"), "/"); map.put(treeTag("MOD"), "%"); + map.put(treeTag("BITOR_ASG"), "|="); + map.put(treeTag("BITXOR_ASG"), "^="); + map.put(treeTag("BITAND_ASG"), "&="); + map.put(treeTag("SL_ASG"), "<<="); + map.put(treeTag("SR_ASG"), ">>="); + map.put(treeTag("USR_ASG"), ">>>="); + map.put(treeTag("PLUS_ASG"), "+="); + map.put(treeTag("MINUS_ASG"), "-="); + map.put(treeTag("MUL_ASG"), "*="); + map.put(treeTag("DIV_ASG"), "/="); + map.put(treeTag("MOD_ASG"), "%="); + OPERATORS = map; } @@ -1234,8 +1246,8 @@ public class PrettyCommentsPrinter extends JCTree.Visitor { try { open(prec, TreeInfo.assignopPrec); printExpr(tree.lhs, TreeInfo.assignopPrec + 1); -// print(" " + operatorName(getTag(tree) - JCTree.ASGOffset) + "= "); - print(" = "); + String opname = operatorName(treeTag(tree)); + print(" " + opname + " "); printExpr(tree.rhs, TreeInfo.assignopPrec); close(prec, TreeInfo.assignopPrec); } catch (IOException e) { diff --git a/test/transform/resource/after-delombok/TestOperators.java b/test/transform/resource/after-delombok/TestOperators.java new file mode 100644 index 00000000..566bedfc --- /dev/null +++ b/test/transform/resource/after-delombok/TestOperators.java @@ -0,0 +1,48 @@ +class TestOperators { + int x = 10; + public void test() { + x = 12; + int a = +x; + boolean d = true; + boolean e = false; + boolean b; + a = -x; + b = !d; + a = ~x; + a = ++x; + a = --x; + a = x++; + a = x--; + b = d || e; + b = d && e; + a = x | a; + a = x ^ a; + a = x & a; + b = a == x; + b = a != x; + b = a < x; + b = a > x; + b = a <= x; + b = a >= x; + a = a << x; + a = a >> x; + a = a >>> x; + a = a + x; + a = a - x; + a = a * x; + a = a / x; + a = a % x; + a |= x; + a ^= x; + a &= x; + a <<= x; + a >>= x; + a >>>= x; + a += x; + a -= x; + a *= x; + a /= x; + a %= x; + a = a > x ? 1 : 0; + } +} diff --git a/test/transform/resource/after-ecj/TestOperators.java b/test/transform/resource/after-ecj/TestOperators.java new file mode 100644 index 00000000..8a78ceeb --- /dev/null +++ b/test/transform/resource/after-ecj/TestOperators.java @@ -0,0 +1,51 @@ +class TestOperators { + int x = 10; + TestOperators() { + super(); + } + public void test() { + x = 12; + int a = (+ x); + boolean d = true; + boolean e = false; + boolean b; + a = (- x); + b = (! d); + a = (~ x); + a = (++ x); + a = (-- x); + a = (x ++); + a = (x --); + b = (d || e); + b = (d && e); + a = (x | a); + a = (x ^ a); + a = (x & a); + b = (a == x); + b = (a != x); + b = (a < x); + b = (a > x); + b = (a <= x); + b = (a >= x); + a = (a << x); + a = (a >> x); + a = (a >>> x); + a = (a + x); + a = (a - x); + a = (a * x); + a = (a / x); + a = (a % x); + a |= x; + a ^= x; + a &= x; + a <<= x; + a >>= x; + a >>>= x; + a += x; + a -= x; + a *= x; + a /= x; + a %= x; + a = ((a > x) ? 1 : 0); + } +} diff --git a/test/transform/resource/before/TestOperators.java b/test/transform/resource/before/TestOperators.java new file mode 100644 index 00000000..566bedfc --- /dev/null +++ b/test/transform/resource/before/TestOperators.java @@ -0,0 +1,48 @@ +class TestOperators { + int x = 10; + public void test() { + x = 12; + int a = +x; + boolean d = true; + boolean e = false; + boolean b; + a = -x; + b = !d; + a = ~x; + a = ++x; + a = --x; + a = x++; + a = x--; + b = d || e; + b = d && e; + a = x | a; + a = x ^ a; + a = x & a; + b = a == x; + b = a != x; + b = a < x; + b = a > x; + b = a <= x; + b = a >= x; + a = a << x; + a = a >> x; + a = a >>> x; + a = a + x; + a = a - x; + a = a * x; + a = a / x; + a = a % x; + a |= x; + a ^= x; + a &= x; + a <<= x; + a >>= x; + a >>>= x; + a += x; + a -= x; + a *= x; + a /= x; + a %= x; + a = a > x ? 1 : 0; + } +} diff --git a/website/features/experimental/index.html b/website/features/experimental/index.html index 16d58050..1128787c 100644 --- a/website/features/experimental/index.html +++ b/website/features/experimental/index.html @@ -32,7 +32,7 @@
New default field modifiers for the 21st century.
@Wither
Immutable 'setters' - methods that create a clone but with one changed field.
-
onMethod= / onConstructor= / onParam
+
onMethod= / onConstructor= / onParam=
Sup dawg, we heard you like annotations, so we put annotations in your annotations so you can annotate while you're annotating.
-- cgit