aboutsummaryrefslogtreecommitdiff
path: root/src/utils/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2018-04-17 04:19:37 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2018-04-17 04:19:37 +0200
commitf540335ef972d84f02efba6dcaf608aec0e19129 (patch)
tree90b3c96253dc86171c6e948739a95ddc431e91b6 /src/utils/lombok/eclipse
parent7e81ac623831c3147e8fba4ca4ebfa021f4f5bd5 (diff)
downloadlombok-f540335ef972d84f02efba6dcaf608aec0e19129.tar.gz
lombok-f540335ef972d84f02efba6dcaf608aec0e19129.tar.bz2
lombok-f540335ef972d84f02efba6dcaf608aec0e19129.zip
[Fixes #1656] Lombok would silently do the wrong thing when using references to `public static final String` fields, instead of actual string literals, there where you can specify strings in lombok annotation parameters, such as `@ToString(of = MyClass.CONSTANT_FIELD)`. We can’t really fix it, but at least now lombok will error when you do that and describe in detail what’s going wrong.
Diffstat (limited to 'src/utils/lombok/eclipse')
-rw-r--r--src/utils/lombok/eclipse/Eclipse.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java
index 18b22256..296c0a19 100644
--- a/src/utils/lombok/eclipse/Eclipse.java
+++ b/src/utils/lombok/eclipse/Eclipse.java
@@ -44,6 +44,8 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
+import lombok.core.AnnotationValues;
+
public class Eclipse {
private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0];
/**
@@ -161,7 +163,7 @@ public class Eclipse {
*/
public static Object calculateValue(Expression e) {
if (e instanceof Literal) {
- ((Literal)e).computeConstant();
+ ((Literal) e).computeConstant();
switch (e.constant.typeID()) {
case TypeIds.T_int: return e.constant.intValue();
case TypeIds.T_byte: return e.constant.byteValue();
@@ -175,13 +177,13 @@ public class Eclipse {
default: return null;
}
} else if (e instanceof ClassLiteralAccess) {
- return Eclipse.toQualifiedName(((ClassLiteralAccess)e).type.getTypeName());
+ return new AnnotationValues.ClassLiteral(Eclipse.toQualifiedName(((ClassLiteralAccess)e).type.getTypeName()));
} else if (e instanceof SingleNameReference) {
- return new String(((SingleNameReference)e).token);
+ return new AnnotationValues.FieldSelect(new String(((SingleNameReference)e).token));
} else if (e instanceof QualifiedNameReference) {
String qName = Eclipse.toQualifiedName(((QualifiedNameReference)e).tokens);
int idx = qName.lastIndexOf('.');
- return idx == -1 ? qName : qName.substring(idx+1);
+ return new AnnotationValues.FieldSelect(idx == -1 ? qName : qName.substring(idx+1));
}
return null;