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


Java AnnotationNode.setMember方法代码示例

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


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

示例1: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
/**
 * Implementation method of the alias annotation processor. This method will 
 * get the list of annotations we aliased from the collector and adds it to
 * aliasAnnotationUsage. The method will also map all members from 
 * aliasAnnotationUsage to the aliased nodes. Should a member stay unmapped,
 * we will ad an error. Further processing of those members is done by the
 * annotations.
 * 
 * @param collector                 reference to the annotation with {@link AnnotationCollector}
 * @param aliasAnnotationUsage      reference to the place of usage of the alias
 * @param aliasAnnotated            reference to the node that has been annotated by the alias
 * @param source                    source unit for error reporting
 * @return list of the new AnnotationNodes
 */
public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) {
    List<AnnotationNode> ret =  getTargetAnnotationList(collector, aliasAnnotationUsage, source);
    Set<String> unusedNames = new HashSet<String>(aliasAnnotationUsage.getMembers().keySet());
    
    for (AnnotationNode an: ret) {
        for (String name : aliasAnnotationUsage.getMembers().keySet()) {
            if (an.getClassNode().hasMethod(name, Parameter.EMPTY_ARRAY)) {
                unusedNames.remove(name);
                an.setMember(name, aliasAnnotationUsage.getMember(name));
            }
        }
    }

    if (!unusedNames.isEmpty()) {
        String message = "Annotation collector got unmapped names "+unusedNames.toString()+".";
        addError(message, aliasAnnotationUsage, source);
    }

    return ret;
}
 
开发者ID:apache,项目名称:groovy,代码行数:35,代码来源:AnnotationCollectorTransform.java

示例2: addTypeCheckingInfoAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
protected void addTypeCheckingInfoAnnotation(final MethodNode node) {
    // TypeChecked$TypeCheckingInfo can not be applied on constructors
    if (node instanceof ConstructorNode) return;

    // if a returned inferred type is available and no @TypeCheckingInfo is on node, then add an
    // annotation to the method node
    ClassNode rtype = getInferredReturnType(node);
    if (rtype != null && node.getAnnotations(TYPECHECKING_INFO_NODE).isEmpty()) {
        AnnotationNode anno = new AnnotationNode(TYPECHECKING_INFO_NODE);
        anno.setMember("version", CURRENT_SIGNATURE_PROTOCOL);
        SignatureCodec codec = SignatureCodecFactory.getCodec(CURRENT_SIGNATURE_PROTOCOL_VERSION, getTransformLoader());
        String genericsSignature = codec.encode(rtype);
        if (genericsSignature != null) {
            ConstantExpression signature = new ConstantExpression(genericsSignature);
            signature.setType(STRING_TYPE);
            anno.setMember("inferredType", signature);
            node.addAnnotation(anno);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:StaticTypeCheckingVisitor.java

示例3: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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 (!checkNotInterface(cNode, MY_TYPE_NAME)) return;
        ClassNode exception = getMemberClassValue(anno, "exception");
        if (exception != null && Undefined.isUndefinedException(exception)) {
            exception = null;
        }
        String message = getMemberStringValue(anno, "message");
        Expression code = anno.getMember("code");
        if (code != null && !(code instanceof ClosureExpression)) {
            addError("Expected closure value for annotation parameter 'code'. Found " + code, cNode);
            return;
        }
        createMethods(cNode, exception, message, (ClosureExpression) code);
        if (code != null) {
            anno.setMember("code", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:26,代码来源:AutoImplementASTTransformation.java

示例4: annotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
protected AnnotationNode annotation(AST annotationNode) {
    annotationBeingDef = true;
    AST node = annotationNode.getFirstChild();
    String name = qualifiedName(node);
    AnnotationNode annotatedNode = new AnnotationNode(ClassHelper.make(name));
    configureAST(annotatedNode, annotationNode);
    while (true) {
        node = node.getNextSibling();
        if (isType(ANNOTATION_MEMBER_VALUE_PAIR, node)) {
            AST memberNode = node.getFirstChild();
            String param = identifier(memberNode);
            Expression expression = expression(memberNode.getNextSibling());
            if (annotatedNode.getMember(param) != null) {
                throw new ASTRuntimeException(memberNode, "Annotation member '" + param + "' has already been associated with a value");
            }
            annotatedNode.setMember(param, expression);
        } else {
            break;
        }
    }
    annotationBeingDef = false;
    return annotatedNode;
}
 
开发者ID:apache,项目名称:groovy,代码行数:24,代码来源:AntlrParserPlugin.java

示例5: disableGrabResolvers

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void disableGrabResolvers(List<? extends AnnotatedNode> nodes) {
	for (AnnotatedNode classNode : nodes) {
		List<AnnotationNode> annotations = classNode.getAnnotations();
		for (AnnotationNode node : new ArrayList<AnnotationNode>(annotations)) {
			if (node.getClassNode().getNameWithoutPackage()
					.equals("GrabResolver")) {
				node.setMember("initClass", new ConstantExpression(false));
			}
		}
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:ArchiveCommand.java

示例6: transformGrabAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void transformGrabAnnotation(AnnotationNode grabAnnotation) {
	grabAnnotation.setMember("initClass", new ConstantExpression(false));
	String value = getValue(grabAnnotation);
	if (value != null && !isConvenienceForm(value)) {
		applyGroupAndVersion(grabAnnotation, value);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:ResolveDependencyCoordinatesTransformation.java

示例7: addDependencyManagementBom

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void addDependencyManagementBom(ModuleNode node, String module) {
	AnnotatedNode annotated = getAnnotatedNode(node);
	if (annotated != null) {
		AnnotationNode bom = getAnnotation(annotated);
		List<Expression> expressions = new ArrayList<Expression>(
				getConstantExpressions(bom.getMember("value")));
		expressions.add(new ConstantExpression(module));
		bom.setMember("value", new ListExpression(expressions));
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:GenericBomAstTransformation.java

示例8: mergeParameters

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private static void mergeParameters(AnnotationNode to, AnnotationNode from) {
    for (String name : from.getMembers().keySet()) {
        if (to.getMember(name) == null) {
            to.setMember(name, from.getMember(name));
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:ASTTransformationCollectorCodeVisitor.java

示例9: extractGrab

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void extractGrab(Expression init, ConstantExpression ce) {
    if (ce.getValue() instanceof AnnotationNode) {
        AnnotationNode annotation = (AnnotationNode) ce.getValue();
        if ((init != null) && (annotation.getMember("initClass") != null)) {
            annotation.setMember("initClass", init);
        }
        String name = annotation.getClassNode().getName();
        if ((GRAB_CLASS_NAME.equals(name))
                || (allowShortGrab && GRAB_SHORT_NAME.equals(name))
                || (grabAliases.contains(name))) {
            grabAnnotations.add(annotation);
        }
        if ((GRABEXCLUDE_CLASS_NAME.equals(name))
                || (allowShortGrabExcludes && GRABEXCLUDE_SHORT_NAME.equals(name))
                || (grabExcludeAliases.contains(name))) {
            grabExcludeAnnotations.add(annotation);
        }
        if ((GRABCONFIG_CLASS_NAME.equals(name))
                || (allowShortGrabConfig && GRABCONFIG_SHORT_NAME.equals(name))
                || (grabConfigAliases.contains(name))) {
            grabConfigAnnotations.add(annotation);
        }
        if ((GRABRESOLVER_CLASS_NAME.equals(name))
                || (allowShortGrabResolver && GRABRESOLVER_SHORT_NAME.equals(name))
                || (grabResolverAliases.contains(name))) {
            grabResolverAnnotations.add(annotation);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:30,代码来源:GrabAnnotationTransformation.java

示例10: setMember

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void setMember(AnnotationNode annotation, String name, String value) {
	ConstantExpression expression = new ConstantExpression(value);
	annotation.setMember(name, expression);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:ResolveDependencyCoordinatesTransformation.java

示例11: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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 (!checkNotInterface(cNode, MY_TYPE_NAME)) return;
        boolean includeFields = memberHasValue(anno, "includeFields", true);
        boolean includeProperties = !memberHasValue(anno, "includeProperties", false);
        boolean includeSuperProperties = memberHasValue(anno, "includeSuperProperties", true);
        boolean useSetters = memberHasValue(anno, "useSetters", true);
        List<String> excludes = getMemberStringList(anno, "excludes");
        List<String> includes = getMemberStringList(anno, "includes");
        boolean allNames = memberHasValue(anno, "allNames", true);
        if (!checkIncludeExcludeUndefinedAware(anno, excludes, includes, MY_TYPE_NAME)) return;
        if (!checkPropertyList(cNode, includes, "includes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false)) return;
        if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false)) return;
        // if @Immutable is found, let it pick up options and do work so we'll skip
        if (hasAnnotation(cNode, ImmutableASTTransformation.MY_TYPE)) return;

        Expression pre = anno.getMember("pre");
        if (pre != null && !(pre instanceof ClosureExpression)) {
            addError("Expected closure value for annotation parameter 'pre'. Found " + pre, cNode);
            return;
        }
        Expression post = anno.getMember("post");
        if (post != null && !(post instanceof ClosureExpression)) {
            addError("Expected closure value for annotation parameter 'post'. Found " + post, cNode);
            return;
        }

        createConstructor(cNode, includeFields, includeProperties, includeSuperProperties, useSetters, excludes, includes, (ClosureExpression) pre, (ClosureExpression) post, source, allNames);
        if (pre != null) {
            anno.setMember("pre", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
        }
        if (post != null) {
            anno.setMember("post", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:43,代码来源:MapConstructorASTTransformation.java

示例12: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
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 (!checkNotInterface(cNode, MY_TYPE_NAME)) return;
        boolean includeFields = memberHasValue(anno, "includeFields", true);
        boolean includeProperties = !memberHasValue(anno, "includeProperties", false);
        boolean includeSuperFields = memberHasValue(anno, "includeSuperFields", true);
        boolean includeSuperProperties = memberHasValue(anno, "includeSuperProperties", true);
        boolean callSuper = memberHasValue(anno, "callSuper", true);
        boolean force = memberHasValue(anno, "force", true);
        boolean defaults = !memberHasValue(anno, "defaults", false);
        boolean useSetters = memberHasValue(anno, "useSetters", true);
        List<String> excludes = getMemberStringList(anno, "excludes");
        List<String> includes = getMemberStringList(anno, "includes");
        boolean allNames = memberHasValue(anno, "allNames", true);
        if (!checkIncludeExcludeUndefinedAware(anno, excludes, includes, MY_TYPE_NAME)) return;
        if (!checkPropertyList(cNode, includes, "includes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false, includeSuperFields)) return;
        if (!checkPropertyList(cNode, excludes, "excludes", anno, MY_TYPE_NAME, includeFields, includeSuperProperties, false, includeSuperFields)) return;
        // if @Immutable is found, let it pick up options and do work so we'll skip
        if (hasAnnotation(cNode, ImmutableASTTransformation.MY_TYPE)) return;
        Expression pre = anno.getMember("pre");
        if (pre != null && !(pre instanceof ClosureExpression)) {
            addError("Expected closure value for annotation parameter 'pre'. Found " + pre, cNode);
            return;
        }
        Expression post = anno.getMember("post");
        if (post != null && !(post instanceof ClosureExpression)) {
            addError("Expected closure value for annotation parameter 'post'. Found " + post, cNode);
            return;
        }
        createConstructor(this, cNode, includeFields, includeProperties, includeSuperFields, includeSuperProperties,
                callSuper, force, excludes, includes, useSetters, defaults, allNames, sourceUnit,
                (ClosureExpression) pre, (ClosureExpression) post);
        if (pre != null) {
            anno.setMember("pre", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
        }
        if (post != null) {
            anno.setMember("post", new ClosureExpression(new Parameter[0], EmptyStatement.INSTANCE));
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:47,代码来源:TupleConstructorASTTransformation.java

示例13: createDelegatesToAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private AnnotationNode createDelegatesToAnnotation(ClassNode target) {
    AnnotationNode delegatesTo = new AnnotationNode(DELEGATES_TO_TYPE);
    delegatesTo.addMember("value", new ClassExpression(getRwClassOf(target)));
    delegatesTo.setMember("strategy", constX(Closure.DELEGATE_ONLY));
    return delegatesTo;
}
 
开发者ID:klum-dsl,项目名称:klum-ast,代码行数:7,代码来源:DelegatesToRWTransformation.java


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