aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
authorMarcel <wittemar@gmail.com>2015-07-27 12:41:05 +0200
committerMarcel <wittemar@gmail.com>2015-07-27 12:41:05 +0200
commite9b71f015628c181a625b62472b6354696d39700 (patch)
tree5109740f62a756dd4c61a5c920abfa620824450c /src/core/lombok/javac
parent59cdad442a9d3582049f64d656fc1277d5ea6d2b (diff)
downloadlombok-e9b71f015628c181a625b62472b6354696d39700.tar.gz
lombok-e9b71f015628c181a625b62472b6354696d39700.tar.bz2
lombok-e9b71f015628c181a625b62472b6354696d39700.zip
implemented support for annotation arrays as annotation attributes in javac
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 0db59da1..ea61a406 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -239,8 +239,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) {
@@ -265,7 +276,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 {