Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

GRAILS-9470 - minor improvement to how annotations are copied

  • Loading branch information...
commit e0892c94b9f951f68203aa7bb2f564907d6ccf8e 1 parent 6042f27
@jeffbrown jeffbrown authored
View
14 ...gin-controllers/src/main/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformer.java
@@ -241,7 +241,7 @@ private MethodNode convertToMethodAction(ClassNode classNode, MethodNode methodN
EMPTY_CLASS_ARRAY,
addOriginalMethodCall(methodNode, initializeActionParameters(
classNode, methodNode, methodNode.getName(), parameters, source, context)));
- method.addAnnotations(methodNode.getAnnotations());
+ copyAnnotations(methodNode, method);
annotateActionMethod(parameters, method);
} else {
annotateActionMethod(parameters, methodNode);
@@ -250,6 +250,18 @@ private MethodNode convertToMethodAction(ClassNode classNode, MethodNode methodN
return method;
}
+ protected void copyAnnotations(final MethodNode from, final MethodNode to) {
+ final List<AnnotationNode> annotationsToCopy = from.getAnnotations();
+ for(final AnnotationNode node : annotationsToCopy) {
+ final AnnotationNode copyOfAnnotationNode = new AnnotationNode(node.getClassNode());
+ final Map<String, Expression> members = node.getMembers();
+ for(final Map.Entry<String, Expression> entry : members.entrySet()) {
+ copyOfAnnotationNode.addMember(entry.getKey(), entry.getValue());
+ }
+ to.addAnnotation(copyOfAnnotationNode);
+ }
+ }
+
private Statement addOriginalMethodCall(MethodNode methodNode, BlockStatement blockStatement) {
if (blockStatement == null) {
Please sign in to comment.
Something went wrong with that request. Please try again.