aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac/handlers/JavacHandlerUtil.java
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2010-11-10 01:44:04 +0100
committerRoel Spilker <r.spilker@gmail.com>2010-11-10 01:44:04 +0100
commitfe7f0db2fce7b4c80853b9aed100908ff1f55f40 (patch)
tree41f7c7a289237153307402b7ebe25e372254ae40 /src/core/lombok/javac/handlers/JavacHandlerUtil.java
parent46d471e9c3dc32b03c34804df1819739a4dffc50 (diff)
downloadlombok-fe7f0db2fce7b4c80853b9aed100908ff1f55f40.tar.gz
lombok-fe7f0db2fce7b4c80853b9aed100908ff1f55f40.tar.bz2
lombok-fe7f0db2fce7b4c80853b9aed100908ff1f55f40.zip
From now on it is possible to specify annotations to be placed on the method
or the parameter of the generated getter/setter methods.
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 5dacf2ca..bf356853 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -42,12 +42,15 @@ import com.sun.tools.javac.tree.JCTree.JCLiteral;
import com.sun.tools.javac.tree.JCTree.JCModifiers;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
+import com.sun.tools.javac.tree.JCTree.JCAssign;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
import com.sun.tools.javac.tree.JCTree.JCImport;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
+import com.sun.tools.javac.tree.JCTree.JCNewArray;
import com.sun.tools.javac.tree.JCTree.JCStatement;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
@@ -567,4 +570,39 @@ public class JavacHandlerUtil {
return problematic;
}
+
+ static List<JCExpression> getAndRemoveAnnotationParameter(JCAnnotation ast, String parameterName) {
+ List<JCExpression> params = List.nil();
+ List<JCExpression> result = List.nil();
+
+ for (JCExpression param : ast.args) {
+ if (param instanceof JCAssign) {
+ JCAssign assign = (JCAssign) param;
+ if (assign.lhs instanceof JCIdent) {
+ JCIdent ident = (JCIdent) assign.lhs;
+ if (parameterName.equals(ident.name.toString())) {
+ if (assign.rhs instanceof JCNewArray) {
+ result = ((JCNewArray) assign.rhs).elems;
+ } else {
+ result = result.append(assign.rhs);
+ }
+ continue;
+ }
+ }
+ }
+
+ params = params.append(param);
+ }
+ ast.args = params;
+ return result;
+ }
+
+ static List<JCAnnotation> copyAnnotations(List<JCExpression> in) {
+ List<JCAnnotation> out = List.nil();
+ for (JCExpression expr : in) {
+ if (!(expr instanceof JCAnnotation)) continue;
+ out = out.append((JCAnnotation) expr.clone());
+ }
+ return out;
+ }
}