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


Java AnnotationNode.addMember方法代码示例

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


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

示例1: createGrabAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private AnnotationNode createGrabAnnotation(String group, String module,
		String version, String classifier, String type, boolean transitive) {
	AnnotationNode annotationNode = new AnnotationNode(new ClassNode(Grab.class));
	annotationNode.addMember("group", new ConstantExpression(group));
	annotationNode.addMember("module", new ConstantExpression(module));
	annotationNode.addMember("version", new ConstantExpression(version));
	if (classifier != null) {
		annotationNode.addMember("classifier", new ConstantExpression(classifier));
	}
	if (type != null) {
		annotationNode.addMember("type", new ConstantExpression(type));
	}
	annotationNode.addMember("transitive", new ConstantExpression(transitive));
	annotationNode.addMember("initClass", new ConstantExpression(false));
	return annotationNode;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:DependencyCustomizer.java

示例2: visitModule

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void visitModule(ModuleNode module) {
	for (ClassNode classNode : module.getClasses()) {
		AnnotationNode annotation = new AnnotationNode(new ClassNode(Grab.class));
		annotation.addMember("value", new ConstantExpression("groovy"));
		classNode.addAnnotation(annotation);
		// We only need to do it at most once
		break;
	}
	// Disable the addition of a static initializer that calls Grape.addResolver
	// because all the dependencies are local now
	disableGrabResolvers(module.getClasses());
	disableGrabResolvers(module.getImports());
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:ArchiveCommand.java

示例3: apply

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Override
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
		GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
				throws CompilationFailedException {
	if (!AstUtils.hasAtLeastOneAnnotation(classNode, "RunWith")) {
		AnnotationNode runWith = new AnnotationNode(ClassHelper.make("RunWith"));
		runWith.addMember("value",
				new ClassExpression(ClassHelper.make("SpringRunner")));
		classNode.addAnnotation(runWith);
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:12,代码来源:SpringTestCompilerAutoConfiguration.java

示例4: transformationOfClassWithExistingManagedDependencies

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Test
public void transformationOfClassWithExistingManagedDependencies() {
	this.moduleNode.setPackage(new PackageNode("foo"));
	ClassNode cls = ClassHelper.make("MyClass");
	this.moduleNode.addClass(cls);
	AnnotationNode annotation = new AnnotationNode(
			ClassHelper.make(DependencyManagementBom.class));
	annotation.addMember("value", new ConstantExpression("test:parent:1.0.0"));
	cls.addAnnotation(annotation);
	this.transformation.visit(new ASTNode[] { this.moduleNode }, this.sourceUnit);
	assertThat(getValue().toString())
			.isEqualTo("[test:parent:1.0.0, test:child:1.0.0]");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:GenericBomAstTransformationTests.java

示例5: apply

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Override
public void apply(GroovyClassLoader loader, GroovyCompilerConfiguration configuration,
		GeneratorContext generatorContext, SourceUnit source, ClassNode classNode)
				throws CompilationFailedException {
	if (!AstUtils.hasAtLeastOneAnnotation(classNode, "RunWith")) {
		AnnotationNode runwith = new AnnotationNode(ClassHelper.make("RunWith"));
		runwith.addMember("value",
				new ClassExpression(ClassHelper.make("SpringJUnit4ClassRunner")));
		classNode.addAnnotation(runwith);
	}
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:12,代码来源:SpringTestCompilerAutoConfiguration.java

示例6: transformationOfClassWithExistingManagedDependencies

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Test
public void transformationOfClassWithExistingManagedDependencies() {
	this.moduleNode.setPackage(new PackageNode("foo"));
	ClassNode cls = ClassHelper.make("MyClass");
	this.moduleNode.addClass(cls);
	AnnotationNode annotation = new AnnotationNode(
			ClassHelper.make(DependencyManagementBom.class));
	annotation.addMember("value", new ConstantExpression("test:parent:1.0.0"));
	cls.addAnnotation(annotation);
	this.transformation.visit(new ASTNode[] { this.moduleNode }, this.sourceUnit);
	assertEquals("[test:parent:1.0.0, test:child:1.0.0]", getValue().toString());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:GenericBomAstTransformationTests.java

示例7: attachGroovydocAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void attachGroovydocAnnotation(ASTNode node, String docCommentNodeText) {
    if (!(node instanceof AnnotatedNode)) {
        return;
    }

    if (!(ATTACHING_RUNTIME_GROOVYDOC_ENABLED || docCommentNodeText.matches(RUNTIME_GROOVYDOC_PATTERN))) {
        return;
    }

    AnnotatedNode annotatedNode = (AnnotatedNode) node;
    AnnotationNode annotationNode = new AnnotationNode(ClassHelper.make(Groovydoc.class));
    annotationNode.addMember(VALUE, new ConstantExpression(docCommentNodeText));
    annotatedNode.addAnnotation(annotationNode);
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:GroovydocManager.java

示例8: createAnnotationNode

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
static AnnotationNode createAnnotationNode(AnnotationStub annotation, AsmReferenceResolver resolver) {
    ClassNode classNode = resolver.resolveClassNullable(Type.getType(annotation.className).getClassName());
    if (classNode == null) {
        // there might be annotations not present in the classpath
        // e.g. java.lang.Synthetic (http://forge.ow2.org/tracker/?aid=307392&group_id=23&atid=100023&func=detail)
        // so skip them
        return null;
    }

    AnnotationNode node = new DecompiledAnnotationNode(classNode);
    for (Map.Entry<String, Object> entry : annotation.members.entrySet()) {
        node.addMember(entry.getKey(), annotationValueToExpression(entry.getValue(), resolver));
    }
    return node;
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:Annotations.java

示例9: copyAnnotatedNodeAnnotations

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
/**
 * Copies all <tt>candidateAnnotations</tt> with retention policy {@link java.lang.annotation.RetentionPolicy#RUNTIME}
 * and {@link java.lang.annotation.RetentionPolicy#CLASS}.
 * <p>
 * Annotations with {@link org.codehaus.groovy.runtime.GeneratedClosure} members are not supported at present.
 */
public static void copyAnnotatedNodeAnnotations(final AnnotatedNode annotatedNode, final List<AnnotationNode> copied, List<AnnotationNode> notCopied) {
    List<AnnotationNode> annotationList = annotatedNode.getAnnotations();
    for (AnnotationNode annotation : annotationList)  {

        List<AnnotationNode> annotations = annotation.getClassNode().getAnnotations(AbstractASTTransformation.RETENTION_CLASSNODE);
        if (annotations.isEmpty()) continue;

        if (hasClosureMember(annotation)) {
            notCopied.add(annotation);
            continue;
        }

        AnnotationNode retentionPolicyAnnotation = annotations.get(0);
        Expression valueExpression = retentionPolicyAnnotation.getMember("value");
        if (!(valueExpression instanceof PropertyExpression)) continue;

        PropertyExpression propertyExpression = (PropertyExpression) valueExpression;
        boolean processAnnotation =
                propertyExpression.getProperty() instanceof ConstantExpression &&
                        (
                                "RUNTIME".equals(((ConstantExpression) (propertyExpression.getProperty())).getValue()) ||
                                        "CLASS".equals(((ConstantExpression) (propertyExpression.getProperty())).getValue())
                        );

        if (processAnnotation)  {
            AnnotationNode newAnnotation = new AnnotationNode(annotation.getClassNode());
            for (Map.Entry<String, Expression> member : annotation.getMembers().entrySet())  {
                newAnnotation.addMember(member.getKey(), member.getValue());
            }
            newAnnotation.setSourcePosition(annotatedNode);

            copied.add(newAnnotation);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:42,代码来源:GeneralUtils.java

示例10: checkForDuplicateAnnotations

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private void checkForDuplicateAnnotations(AnnotatedNode node, Map<String, List<AnnotationNode>> runtimeAnnotations) {
    for (Map.Entry<String, List<AnnotationNode>> next : runtimeAnnotations.entrySet()) {
        if (next.getValue().size() > 1) {
            ClassNode repeatable = null;
            AnnotationNode repeatee = next.getValue().get(0);
            List<AnnotationNode> repeateeAnnotations = repeatee.getClassNode().getAnnotations();
            for (AnnotationNode anno : repeateeAnnotations) {
                ClassNode annoClassNode = anno.getClassNode();
                if (annoClassNode.getName().equals("java.lang.annotation.Repeatable")) {
                    Expression value = anno.getMember("value");
                    if (value instanceof ClassExpression) {
                        ClassExpression ce = (ClassExpression) value;
                        if (ce.getType() != null && ce.getType().isAnnotationDefinition()) {
                            repeatable = ce.getType();
                            break;
                        }
                    }
                }
            }
            if (repeatable != null) {
                AnnotationNode collector = new AnnotationNode(repeatable);
                collector.setRuntimeRetention(true); // checked earlier
                List<Expression> annos = new ArrayList<Expression>();
                for (AnnotationNode an : next.getValue()) {
                    annos.add(new AnnotationConstantExpression(an));
                }
                collector.addMember("value", new ListExpression(annos));
                node.addAnnotation(collector);
                node.getAnnotations().removeAll(next.getValue());
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:34,代码来源:ExtendedVerifier.java

示例11: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
    init(nodes, source);

    annotatedField = (FieldNode) nodes[1];
    annotation = (AnnotationNode) nodes[0];

    AnnotationNode fieldAnnotation = getOrCreateFieldAnnotation();
    Expression existingType = fieldAnnotation.getMember("value");

    if (existingType != null)
        addError("Combining a FieldType with deprecated @ReadOnly annotation is illegal.", annotatedField);

    fieldAnnotation.addMember("value", propX(classX(FieldType.class), FieldType.PROTECTED.name()));
}
 
开发者ID:klum-dsl,项目名称:klum-ast,代码行数:16,代码来源:FieldTypeDeprecationTransformation.java

示例12: createGrabAnnotation

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
private AnnotationNode createGrabAnnotation() {
	ClassNode classNode = new ClassNode(Grab.class);
	AnnotationNode annotationNode = new AnnotationNode(classNode);
	annotationNode.addMember("value", new ConstantExpression("spring-core"));
	return annotationNode;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:7,代码来源:ResolveDependencyCoordinatesTransformationTests.java

示例13: copyMembers

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

示例14: visit

import org.codehaus.groovy.ast.AnnotationNode; //导入方法依赖的package包/类
public List<AnnotationNode> visit(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, AnnotatedNode aliasAnnotated, SourceUnit source) {
    AnnotationNode node = new AnnotationNode(COMPILESTATIC_NODE);
    node.addMember("value", new PropertyExpression(new ClassExpression(TYPECHECKINGMODE_NODE), "SKIP"));
    return Collections.singletonList(node);
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:CompileDynamicProcessor.java

示例15: 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.addMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。