本文整理汇总了Java中org.codehaus.groovy.ast.ClassNode.addAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java ClassNode.addAnnotation方法的具体用法?Java ClassNode.addAnnotation怎么用?Java ClassNode.addAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.ClassNode
的用法示例。
在下文中一共展示了ClassNode.addAnnotation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitModule
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的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
示例2: addEnableAutoConfigurationAnnotation
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
private void addEnableAutoConfigurationAnnotation(SourceUnit source,
ClassNode classNode) {
if (!hasEnableAutoConfigureAnnotation(classNode)) {
AnnotationNode annotationNode = new AnnotationNode(
ClassHelper.make("EnableAutoConfiguration"));
classNode.addAnnotation(annotationNode);
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:SpringBootCompilerAutoConfiguration.java
示例3: apply
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的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.ClassNode; //导入方法依赖的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: transformationOfAnnotationOnClass
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
@Test
public void transformationOfAnnotationOnClass() {
ClassNode classNode = new ClassNode("Test", 0, new ClassNode(Object.class));
classNode.addAnnotation(this.grabAnnotation);
this.moduleNode.addClass(classNode);
assertGrabAnnotationHasBeenTransformed();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:ResolveDependencyCoordinatesTransformationTests.java
示例6: call
import org.codehaus.groovy.ast.ClassNode; //导入方法依赖的package包/类
/**
* {@inheritDoc}
* @see org.codehaus.groovy.control.CompilationUnit.PrimaryClassNodeOperation#call(org.codehaus.groovy.control.SourceUnit, org.codehaus.groovy.classgen.GeneratorContext, org.codehaus.groovy.ast.ClassNode)
*/
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
// Disable global transformations
classNode.addAnnotation(new AnnotationNode(ClassHelper.make(GroovyASTTransformation.class)));
for(ImportNode im: source.getAST().getImports()) {
for(AnnotationNode an: im.getAnnotations()) {
log.info("AnnotationNode: [{}]", an.getClassNode().getName());
}
}
}