本文整理汇总了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);
}
}
示例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());
}
示例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);
}
示例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;
}
示例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);
}
}
}
示例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());
}
}
}
}
示例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()));
}
示例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());
}
}
示例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);
}
示例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;
}