Java Code Examples for org.codehaus.groovy.ast.AnnotationNode#isBuiltIn()

The following examples show how to use org.codehaus.groovy.ast.AnnotationNode#isBuiltIn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResolveVisitor.java    From groovy with Apache License 2.0 5 votes vote down vote up
@Override
public void visitAnnotations(final AnnotatedNode node) {
    List<AnnotationNode> annotations = node.getAnnotations();
    if (annotations.isEmpty()) return;
    Map<String, AnnotationNode> tmpAnnotations = new HashMap<>();
    for (AnnotationNode an : annotations) {
        // skip built-in properties
        if (an.isBuiltIn()) continue;
        ClassNode annType = an.getClassNode();
        resolveOrFail(annType, " for annotation", an);
        for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) {
            Expression newValue = transform(member.getValue());
            Expression adjusted = transformInlineConstants(newValue);
            member.setValue(adjusted);
            checkAnnotationMemberValue(adjusted);
        }
        if (annType.isResolved()) {
            Class<?> annTypeClass = annType.getTypeClass();
            Retention retAnn = annTypeClass.getAnnotation(Retention.class);
            if (retAnn != null && !retAnn.value().equals(RetentionPolicy.SOURCE) && !isRepeatable(annTypeClass)) {
                // remember non-source/non-repeatable annos (auto collecting of Repeatable annotations is handled elsewhere)
                AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an);
                if (anyPrevAnnNode != null) {
                    addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an);
                }
            }
        }
    }
}
 
Example 2
Source File: AsmClassGenerator.java    From groovy with Apache License 2.0 5 votes vote down vote up
private void visitAnnotations(final AnnotatedNode targetNode, final AnnotatedNode sourceNode, final Object visitor) {
    for (AnnotationNode an : sourceNode.getAnnotations()) {
        // skip built-in properties
        if (an.isBuiltIn()) continue;
        if (an.hasSourceRetention()) continue;

        AnnotationVisitor av = getAnnotationVisitor(targetNode, an, visitor);
        visitAnnotationAttributes(an, av);
        av.visitEnd();
    }
}
 
Example 3
Source File: AsmClassGenerator.java    From groovy with Apache License 2.0 5 votes vote down vote up
private void visitParameterAnnotations(final Parameter parameter, final int paramNumber, final MethodVisitor mv) {
    for (AnnotationNode an : parameter.getAnnotations()) {
        // skip built-in properties
        if (an.isBuiltIn()) continue;
        if (an.hasSourceRetention()) continue;

        final String annotationDescriptor = BytecodeHelper.getTypeDescription(an.getClassNode());
        AnnotationVisitor av = mv.visitParameterAnnotation(paramNumber, annotationDescriptor, an.hasRuntimeRetention());
        visitAnnotationAttributes(an, av);
        av.visitEnd();
    }
}