mirror of
https://github.com/tiennm99/lombok.git
synced 2026-09-20 04:23:33 +00:00
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.
This commit is contained in:
1 parent
df69425550
commit
95cf815285
9 files changed
+45
-45
No files matched your search
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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}))");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class PlaceFillerToMakeSurePositionIsRelevant {
|
||||
}
|
||||
@lombok.Getter(onMethod=@_(@Deprecated))
|
||||
@lombok.Getter(onMethod=@__(@Deprecated))
|
||||
class GetterOnMethodErrors {
|
||||
private int test;
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
@@ -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}))
|
||||
@@ -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}))
|
||||
Reference in new issue
Block a user