本文整理汇总了Java中org.codehaus.groovy.transform.GroovyASTTransformation类的典型用法代码示例。如果您正苦于以下问题:Java GroovyASTTransformation类的具体用法?Java GroovyASTTransformation怎么用?Java GroovyASTTransformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GroovyASTTransformation类属于org.codehaus.groovy.transform包,在下文中一共展示了GroovyASTTransformation类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: call
import org.codehaus.groovy.transform.GroovyASTTransformation; //导入依赖的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());
}
}
}
示例2: addTransform
import org.codehaus.groovy.transform.GroovyASTTransformation; //导入依赖的package包/类
public void addTransform(Class<? extends ASTTransformation> transform, ASTNode node) {
GroovyASTTransformation annotation = transform.getAnnotation(GroovyASTTransformation.class);
if (annotation == null) return;
Set<ASTNode> nodes = getTransformInstances().get(annotation.phase()).get(transform);
if (nodes == null) {
nodes = new LinkedHashSet<ASTNode>();
getTransformInstances().get(annotation.phase()).put(transform, nodes);
}
nodes.add(node);
}
示例3: visitAnnotationsOnNode
import org.codehaus.groovy.transform.GroovyASTTransformation; //导入依赖的package包/类
private void visitAnnotationsOnNode(AnnotatedNode node, ClassNode owner) {
for (AnnotationNode annotationNode : node.getAnnotations()) {
Class<? extends ASTTransformation> transformationClass = transformations.get(annotationNode.getClassNode().getName());
if (transformationClass == null) continue;
GroovyASTTransformation annotation = transformationClass.getAnnotation(GroovyASTTransformation.class);
if (annotation == null) continue;
// Set<ASTNode> nodes = owner.getTransforms(annotation.phase()).get(transformationClass);
// if (nodes != null && !nodes.isEmpty()) continue;
owner.addTransform(transformationClass, annotationNode);
}
}
示例4: getGroovyAnnotation
import org.codehaus.groovy.transform.GroovyASTTransformation; //导入依赖的package包/类
/**
* Creates an {@link AnnotationNode} of type {@link GroovyASTTransformation}.
*
* @param compilePhase the target {@link CompilePhase} used as value of the
* {@link GroovyASTTransformation} annotation
* @return an instance of {@link GroovyASTTransformation} annotation
* @since 0.2.0
*/
public static AnnotationNode getGroovyAnnotation(final CompilePhase compilePhase) {
final PropertyExpression valueExpr = getCompilePhaseAsPropertyExpression(compilePhase);
return A.NODES.annotation(GroovyASTTransformation.class)
.member("phase", valueExpr)
.build();
}