aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2018-04-10 00:41:13 +0200
committerGitHub <noreply@github.com>2018-04-10 00:41:13 +0200
commit8614edfd85ad6fc65598d1d13a370d7562ad57db (patch)
tree57c989d0feeeefcf4e87df6921468e23327cca1e
parent22e9c25db63426c542ae0a655f29b69180bd92f7 (diff)
parente9b71f015628c181a625b62472b6354696d39700 (diff)
downloadlombok-8614edfd85ad6fc65598d1d13a370d7562ad57db.tar.gz
lombok-8614edfd85ad6fc65598d1d13a370d7562ad57db.tar.bz2
lombok-8614edfd85ad6fc65598d1d13a370d7562ad57db.zip
Merge pull request #886 from balta3/annotationarrays
implemented support for annotation arrays as annotation attributes in javac
-rw-r--r--src/core/lombok/core/AnnotationValues.java4
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java23
2 files changed, 25 insertions, 2 deletions
diff --git a/src/core/lombok/core/AnnotationValues.java b/src/core/lombok/core/AnnotationValues.java
index d04797cb..df426a65 100644
--- a/src/core/lombok/core/AnnotationValues.java
+++ b/src/core/lombok/core/AnnotationValues.java
@@ -298,6 +298,10 @@ public class AnnotationValues<A extends Annotation> {
}
}
+ if (guess instanceof AnnotationValues) {
+ return ((AnnotationValues) guess).getInstance();
+ }
+
throw new AnnotationValueDecodeFail(v,
"Can't translate a " + guess.getClass() + " to the expected " + expected, pos);
}
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 65d09a9a..fda1a5d2 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -321,8 +321,19 @@ public class JavacHandlerUtil {
* @param node A Lombok AST node representing an annotation in source code.
*/
public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type, final JavacNode node) {
+ return createAnnotation(type, (JCAnnotation) node.get(), node);
+ }
+
+ /**
+ * Creates an instance of {@code AnnotationValues} for the provided AST Node
+ * and Annotation expression.
+ *
+ * @param type An annotation class type, such as {@code lombok.Getter.class}.
+ * @param anno the annotation expression
+ * @param node A Lombok AST node representing an annotation in source code.
+ */
+ public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type, JCAnnotation anno, final JavacNode node) {
Map<String, AnnotationValue> values = new HashMap<String, AnnotationValue>();
- JCAnnotation anno = (JCAnnotation) node.get();
List<JCExpression> arguments = anno.getArguments();
for (JCExpression arg : arguments) {
@@ -347,7 +358,15 @@ public class JavacHandlerUtil {
for (JCExpression inner : elems) {
raws.add(inner.toString());
expressions.add(inner);
- guesses.add(calculateGuess(inner));
+ if (inner instanceof JCAnnotation) {
+ try {
+ guesses.add(createAnnotation((Class<A>) Class.forName(inner.type.toString()), (JCAnnotation) inner, node));
+ } catch (ClassNotFoundException ex) {
+ throw new IllegalStateException(ex);
+ }
+ } else {
+ guesses.add(calculateGuess(inner));
+ }
positions.add(inner.pos());
}
} else {