Examples of AnnotationNode


Examples of org.codehaus.groovy.ast.AnnotationNode

        super(node);
        setType(node.getClassNode());
    }

    public void visit(GroovyCodeVisitor visitor) {
        AnnotationNode node = (AnnotationNode) getValue();
        Map<String, Expression> attrs = node.getMembers();
        for (Expression expr : attrs.values()) {
            expr.visit(visitor);
        }
    }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

        if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
            throw new GroovyBugError("Internal error: expecting [AnnotationNode, AnnotatedNode] but got: " + Arrays.asList(nodes));
        }

        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;

        if (parent instanceof FieldNode) {
            FieldNode fNode = (FieldNode) parent;
            ClassNode cNode = fNode.getDeclaringClass();
            if (cNode.getProperty(fNode.getName()) == null) {
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

        if (!(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
            throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
        }

        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;

        if (parent instanceof ClassNode) {
            visitClassNode((ClassNode) parent);
        } else if (parent instanceof FieldNode) {
            visitFieldNode((FieldNode) parent);
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

        if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
            throw new GroovyBugError("Internal error: expecting [AnnotationNode, AnnotatedNode] but got: " + Arrays.asList(nodes));
        }

        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;

        if (parent instanceof ClassNode) {
            ClassNode cNode = (ClassNode) parent;
            if (cNode.isInterface()) {
                addError("Error processing interface '" + cNode.getName() +
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

    if (!(firstNode instanceof AnnotationNode) || !(secondNode instanceof AnnotatedNode)) {
      throw new RuntimeException("Internal error: wrong types: " + firstNode.getClass().getName() +
          " / " + secondNode.getClass().getName());
    }

    final AnnotationNode grailsCacheAnnotationNode = (AnnotationNode) firstNode;
    final AnnotatedNode annotatedNode = (AnnotatedNode) secondNode;
    final AnnotationNode springCacheAnnotationNode = getCorrespondingSpringAnnotation(
        grailsCacheAnnotationNode);
    annotatedNode.addAnnotation(springCacheAnnotationNode);
  }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

  protected AnnotationNode getCorrespondingSpringAnnotation(final AnnotationNode grailsCacheAnnotationNode) {
    final Map<String, Expression> grailsAnnotationMembers = grailsCacheAnnotationNode.getMembers();

    final ClassNode springCacheAnnotationClassNode = GRAILS_ANNOTATION_CLASS_NODE_TO_SPRING_ANNOTATION_CLASS_NODE.get(
        grailsCacheAnnotationNode.getClassNode());
    final AnnotationNode springCacheAnnotationNode = new AnnotationNode(springCacheAnnotationClassNode);
    for (Map.Entry<String, Expression> entry : grailsAnnotationMembers.entrySet()) {
      springCacheAnnotationNode.addMember(entry.getKey(), entry.getValue());
    }
    return springCacheAnnotationNode;
  }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

     * @param attrName
     * @param expression
     * @param attrType
     */
    protected void visitAnnotationExpression(String attrName, AnnotationConstantExpression expression, Class attrType) {
        AnnotationNode annotationNode = (AnnotationNode) expression.getValue();
        AnnotationVisitor visitor = new AnnotationVisitor(this.source, this.errorCollector);
        visitor.visit(annotationNode);
    }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

        super(node);
        setType(node.getClassNode());
    }
   
    public void visit(GroovyCodeVisitor visitor) {
        AnnotationNode node = (AnnotationNode) getValue();
        Map attrs = node.getMembers();
        for(Iterator it = attrs.values().iterator(); it.hasNext(); ) {
            ((Expression) it.next()).visit(visitor);
        }
    }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

                }
            } else {
                constructorNode = new ConstructorNode(Modifier.PUBLIC, constructorBody);
                classNode.addConstructor(constructorNode);
            }
            constructorNode.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
            return constructorNode;
        }
        else {
            // create new constructor, restoring default constructor if there is none
            ConstructorNode cn = findConstructor(classNode, constructorParams);
            if (cn == null) {
                cn = new ConstructorNode(Modifier.PUBLIC, copyParameters(constructorParams, genericsPlaceholders), null, constructorBody);
                classNode.addConstructor(cn);
            }
            else {
                List<AnnotationNode> annotations = cn.getAnnotations(new ClassNode(GrailsDelegatingConstructor.class));
                if (annotations.size() == 0) {
                    Statement code = cn.getCode();
                    constructorBody.addStatement(code);
                    cn.setCode(constructorBody);
                }
            }

            ConstructorNode defaultConstructor = getDefaultConstructor(classNode);
            if (defaultConstructor == null) {
                // add empty
                classNode.addConstructor(new ConstructorNode(Modifier.PUBLIC, new BlockStatement()));
            }
            cn.addAnnotation(new AnnotationNode(new ClassNode(GrailsDelegatingConstructor.class)));
            return cn;
        }
    }
View Full Code Here

Examples of org.codehaus.groovy.ast.AnnotationNode

     * @param annotationClass The annotation class
     */
    public static AnnotationNode addAnnotationOrGetExisting(ClassNode classNode, Class<? extends Annotation> annotationClass, Map<String, Object> members) {
        List<AnnotationNode> annotations = classNode.getAnnotations();
        ClassNode annotationClassNode = ClassHelper.make(annotationClass);
        AnnotationNode annotationToAdd = new AnnotationNode(annotationClassNode);
        if (annotations.isEmpty()) {
            classNode.addAnnotation(annotationToAdd);
        }
        else {
            AnnotationNode existing = findAnnotation(annotationClassNode, annotations);
            if (existing != null){
                annotationToAdd = existing;
            }
            else {
                classNode.addAnnotation(annotationToAdd);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.