Package org.codehaus.groovy.ast

Examples of org.codehaus.groovy.ast.AnnotationNode


  public void visit(final ASTNode[] astNodes, final SourceUnit source) {
    if (!(astNodes[0] instanceof AnnotationNode) || !(astNodes[1] instanceof FieldNode)) {
      throw new RuntimeException("Internal error: wrong types: $node.class / $parent.class");
    }

    final AnnotationNode annotationNode = (AnnotationNode) astNodes[0];
    final FieldNode fieldNode = (FieldNode) astNodes[1];
    final Map<String, Expression> members = annotationNode.getMembers();
    if(members == null || (!members.containsKey("code") && !members.containsKey("value"))) {
      final String message = "The @BindingFormat annotation on the field ["
          + fieldNode.getName() +
          "] in class [" +
          fieldNode.getDeclaringClass().getName() +
View Full Code Here


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

        final AnnotatedNode targetClass = (AnnotatedNode) nodes[1];
        final AnnotationNode activeObjectAnnotation = (AnnotationNode) nodes[0];

        final String actorFieldName = lookupActorFieldName(activeObjectAnnotation);
        final String actorGroupName = lookupActorGroupName(activeObjectAnnotation);

        if (!(targetClass instanceof ClassNode))
            throw new GroovyBugError("Class annotation " + activeObjectAnnotation.getClassNode().getName() + " annotated no Class, this must not happen.");

        final ClassNode classNode = (ClassNode) targetClass;

        final boolean rootActiveObject = isRootActiveObject(classNode);
        if (!rootActiveObject && !actorFieldName.equals(ActiveObject.INTERNAL_ACTIVE_OBJECT_ACTOR)) {
View Full Code Here

    @Override
    public void visit(final ASTNode[] nodes, final SourceUnit source) {
        init(nodes);

        final AnnotatedNode fieldNode = (AnnotatedNode) nodes[1];
        final AnnotationNode annotation = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(annotation.getClassNode()) || !(fieldNode instanceof FieldNode)) return;

        final Expression classExpression;
        final Collection<Expression> values = annotation.getMembers().values();
        final Expression value = values.isEmpty() ? null : values.iterator().next();
        if (value != null && value instanceof ClassExpression) {
            classExpression = value;
        } else {
            classExpression = new ClassExpression(ClassHelper.make(GParsPoolUtil.class));
View Full Code Here

    private static final Expression NULL_EXPR = ConstantExpression.NULL;

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];

        if (parent instanceof FieldNode) {
            final FieldNode fieldNode = (FieldNode) parent;
            visitField(node, fieldNode);
        }
View Full Code Here

                            returnType,
                            newParams,
                            ClassNode.EMPTY_ARRAY,
                            body
                    );
                    impl.addAnnotation(new AnnotationNode(COMPILESTATIC_CLASSNODE));
                    cNode.addMethod(impl);
                }
            }
        }
    }
View Full Code Here

    private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;

        if (parent instanceof ClassNode) {
            processClass((ClassNode) parent);
        }
    }
View Full Code Here

        }
        if (originalMethod!=null) {
            forwarder.setGenericsTypes(originalMethod.getGenericsTypes());
        }
        // add a helper annotation indicating that it is a bridge method
        AnnotationNode bridgeAnnotation = new AnnotationNode(Traits.TRAITBRIDGE_CLASSNODE);
        bridgeAnnotation.addMember("traitClass", new ClassExpression(trait));
        bridgeAnnotation.addMember("desc", new ConstantExpression(BytecodeHelper.getMethodDescriptor(helperMethod.getReturnType(), traitMethodParams)));
        forwarder.addAnnotation(
                bridgeAnnotation
        );

        if (!shouldSkipMethod(targetNode, forwarder.getName(), forwarderParams)) {
View Full Code Here

    private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) return;
        String value = getMemberStringValue(node, "value");

        if (parent instanceof MethodNode) {
            MethodNode mNode = (MethodNode) parent;
            if (mNode.isAbstract()) {
View Full Code Here

    private static final ClassNode SERIALIZABLE_TYPE = make(Serializable.class);

    public void visit(ASTNode[] nodes, SourceUnit source) {
        init(nodes, source);
        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode anno = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(anno.getClassNode())) return;

        if (parent instanceof ClassNode) {
            ClassNode cNode = (ClassNode) parent;
            if (!hasNoargConstructor(cNode)) {
                addError(MY_TYPE_NAME + ": An Externalizable class requires a no-arg constructor but none found", cNode);
View Full Code Here

        if (nodes.length != 2 || !(nodes[0] instanceof AnnotationNode) || !(nodes[1] instanceof AnnotatedNode)) {
            internalError("Expecting [AnnotationNode, AnnotatedClass] but got: " + Arrays.asList(nodes));
        }

        AnnotatedNode parent = (AnnotatedNode) nodes[1];
        AnnotationNode node = (AnnotationNode) nodes[0];
        if (!MY_TYPE.equals(node.getClassNode())) {
            internalError("Transformation called from wrong annotation: " + node.getClassNode().getName());
        }

        boolean autoFlag = determineAutoFlag(node.getMember("auto"));
        Expression value = node.getMember("value");

        if (parent instanceof ClassNode) {
            newifyClass((ClassNode) parent, autoFlag, determineClasses(value, false));
        } else if (parent instanceof MethodNode || parent instanceof FieldNode) {
            newifyMethodOrField(parent, autoFlag, determineClasses(value, false));
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.AnnotationNode

Copyright © 2018 www.massapicom. 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.