当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationNode.getMembers方法代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.AnnotationNode.getMembers方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationNode.getMembers方法的具体用法?Java AnnotationNode.getMembers怎么用?Java AnnotationNode.getMembers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.ast.AnnotationNode的用法示例。


在下文中一共展示了AnnotationNode.getMembers方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit source) {
    AnnotationNode annotationInformation = (AnnotationNode) nodes[0];
    Map<String,Expression> members = annotationInformation.getMembers();
    Expression extensions = members.get("extensions");
    AnnotatedNode node = (AnnotatedNode) nodes[1];
    StaticTypeCheckingVisitor visitor = null;
    if (node instanceof ClassNode) {
        ClassNode classNode = (ClassNode) node;
        visitor = newVisitor(source, classNode);
        visitor.setCompilationUnit(compilationUnit);
        addTypeCheckingExtensions(visitor, extensions);
        visitor.initialize();
        visitor.visitClass(classNode);
    } else if (node instanceof MethodNode) {
        MethodNode methodNode = (MethodNode) node;
        visitor = newVisitor(source, methodNode.getDeclaringClass());
        visitor.setCompilationUnit(compilationUnit);
        addTypeCheckingExtensions(visitor, extensions);
        visitor.setMethodsToBeVisited(Collections.singleton(methodNode));
        visitor.initialize();
        visitor.visitMethod(methodNode);
    } else {
        source.addError(new SyntaxException(STATIC_ERROR_PREFIX + "Unimplemented node type",
                node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()));
    }
    if (visitor != null) {
        visitor.performSecondPass();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:30,代码来源:StaticTypesTransformation.java

示例2: hasClosureMember

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private static boolean hasClosureMember(AnnotationNode annotation) {

        Map<String, Expression> members = annotation.getMembers();
        for (Map.Entry<String, Expression> member : members.entrySet())  {
            if (member.getValue() instanceof ClosureExpression) return true;

            if (member.getValue() instanceof ClassExpression)  {
                ClassExpression classExpression = (ClassExpression) member.getValue();
                Class<?> typeClass = classExpression.getType().isResolved() ? classExpression.getType().redirect().getTypeClass() : null;
                if (typeClass != null && GeneratedClosure.class.isAssignableFrom(typeClass)) return true;
            }
        }

        return false;
    }
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:GeneralUtils.java

示例3: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public void visit(GroovyCodeVisitor visitor) {
    AnnotationNode node = (AnnotationNode) getValue();
    Map<String, Expression> attrs = node.getMembers();
    for (Expression expr : attrs.values()) {
        expr.visit(visitor);
    }
    super.visit(visitor);
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:AnnotationConstantExpression.java

示例4: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public AnnotationNode visit(AnnotationNode node) {
    this.annotation = node;
    this.reportClass = node.getClassNode();

    if (!isValidAnnotationClass(node.getClassNode())) {
        addError("class " + node.getClassNode().getName() + " is not an annotation");
        return node;
    }

    // check if values have been passed for all annotation attributes that don't have defaults
    if (!checkIfMandatoryAnnotationValuesPassed(node)) {
        return node;
    }

    // if enum constants have been used, check if they are all valid
    if (!checkIfValidEnumConstsAreUsed(node)) {
        return node;
    }
    
    Map<String, Expression> attributes = node.getMembers();
    for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
        String attrName = entry.getKey();
        Expression attrExpr = transformInlineConstants(entry.getValue());
        entry.setValue(attrExpr);
        ClassNode attrType = getAttributeType(node, attrName);
        visitExpression(attrName, attrExpr, attrType);
    }
    VMPluginFactory.getPlugin().configureAnnotation(node);
    return this.annotation;
}
 
开发者ID:apache,项目名称:groovy,代码行数:31,代码来源:AnnotationVisitor.java

示例5: checkIfValidEnumConstsAreUsed

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private boolean checkIfValidEnumConstsAreUsed(AnnotationNode node) {
    Map<String, Expression> attributes = node.getMembers();
    for (Map.Entry<String, Expression> entry : attributes.entrySet()) {
        if (!validateEnumConstant(entry.getValue()))
            return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:AnnotationVisitor.java

示例6: checkIfMandatoryAnnotationValuesPassed

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private boolean checkIfMandatoryAnnotationValuesPassed(AnnotationNode node) {
    boolean ok = true;
    Map attributes = node.getMembers();
    ClassNode classNode = node.getClassNode();
    for (MethodNode mn : classNode.getMethods()) {
        String methodName = mn.getName();
        // if the annotation attribute has a default, getCode() returns a ReturnStatement with the default value
        if (mn.getCode() == null && !attributes.containsKey(methodName)) {
            addError("No explicit/default value found for annotation attribute '" + methodName + "'", node);
            ok = false;
        }
    }
    return ok;
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:AnnotationVisitor.java

示例7: printAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void printAnnotation(PrintWriter out, AnnotationNode annotation) {
    out.print("@" + annotation.getClassNode().getName().replace('$', '.') + "(");
    boolean first = true;
    Map<String, Expression> members = annotation.getMembers();
    for (Map.Entry<String, Expression> entry : members.entrySet()) {
        String key = entry.getKey();
        if (first) first = false;
        else out.print(", ");
        out.print(key + "=" + getAnnotationValue(entry.getValue()).replace('$', '.'));
    }
    out.print(") ");
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:JavaStubGenerator.java

示例8: copyMembers

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private static void copyMembers(final AnnotationNode from, final AnnotationNode to) {
    Map<String, Expression> members = from.getMembers();
    copyMembers(members, to);
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:AnnotationCollectorTransform.java

示例9: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Override
public void visit(final ASTNode[] nodes, final SourceUnit source) {
    AnnotationNode annotationInformation = (AnnotationNode) nodes[0];
    AnnotatedNode node = (AnnotatedNode) nodes[1];
    StaticTypeCheckingVisitor visitor = null;
    Map<String,Expression> members = annotationInformation.getMembers();
    Expression extensions = members.get("extensions");
    if (node instanceof ClassNode) {
        ClassNode classNode = (ClassNode) node;
        visitor = newVisitor(source, classNode);
        visitor.setCompilationUnit(compilationUnit);
        addTypeCheckingExtensions(visitor, extensions);
        classNode.putNodeMetaData(WriterControllerFactory.class, factory);
        node.putNodeMetaData(STATIC_COMPILE_NODE, !visitor.isSkipMode(node));
        visitor.initialize();
        visitor.visitClass(classNode);
    } else if (node instanceof MethodNode) {
        MethodNode methodNode = (MethodNode) node;
        ClassNode declaringClass = methodNode.getDeclaringClass();
        visitor = newVisitor(source, declaringClass);
        visitor.setCompilationUnit(compilationUnit);
        addTypeCheckingExtensions(visitor, extensions);
        methodNode.putNodeMetaData(STATIC_COMPILE_NODE, !visitor.isSkipMode(node));
        if (declaringClass.getNodeMetaData(WriterControllerFactory.class) == null) {
            declaringClass.putNodeMetaData(WriterControllerFactory.class, factory);
        }
        visitor.setMethodsToBeVisited(Collections.singleton(methodNode));
        visitor.initialize();
        visitor.visitMethod(methodNode);
    } else {
        source.addError(new SyntaxException(STATIC_ERROR_PREFIX + "Unimplemented node type",
                node.getLineNumber(), node.getColumnNumber(), node.getLastLineNumber(), node.getLastColumnNumber()));
    }
    if (visitor != null) {
        visitor.performSecondPass();
    }
    StaticCompilationTransformer transformer = new StaticCompilationTransformer(source, visitor);
    if (node instanceof ClassNode) {
        transformer.visitClass((ClassNode) node);
    } else if (node instanceof MethodNode) {
        transformer.visitMethod((MethodNode) node);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:44,代码来源:StaticCompileTransformation.java


注:本文中的org.codehaus.groovy.ast.AnnotationNode.getMembers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。