本文整理汇总了Java中org.codehaus.groovy.transform.ASTTransformation类的典型用法代码示例。如果您正苦于以下问题:Java ASTTransformation类的具体用法?Java ASTTransformation怎么用?Java ASTTransformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ASTTransformation类属于org.codehaus.groovy.transform包,在下文中一共展示了ASTTransformation类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
private void initialize(final SourceUnit source) {
ServiceLoaderUtils.load(getClass().getClassLoader(), "META-INF/annotations/", AnnotationHandler.class, new ServiceLoaderUtils.LineProcessor() {
@Override
@SuppressWarnings("unchecked")
public void process(@Nonnull ClassLoader classLoader, @Nonnull Class<?> type, @Nonnull String line) {
String[] parts = line.trim().split("=");
String annotationClassName = parts[0].trim();
String transformationClassName = parts[1].trim();
try {
Class<?> transformationClass = classLoader.loadClass(transformationClassName);
transformations.put(annotationClassName, (Class<? extends ASTTransformation>) transformationClass);
} catch (Exception e) {
source.addException(e);
}
}
});
}
示例2: GroovyCompiler
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
/**
* Create a new {@link GroovyCompiler} instance.
* @param configuration the compiler configuration
*/
public GroovyCompiler(final GroovyCompilerConfiguration configuration) {
this.configuration = configuration;
this.loader = createLoader(configuration);
DependencyResolutionContext resolutionContext = new DependencyResolutionContext();
AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create(this.loader,
configuration.getRepositoryConfiguration(), resolutionContext);
GrapeEngineInstaller.install(grapeEngine);
this.loader.getConfiguration()
.addCompilationCustomizers(new CompilerAutoConfigureCustomizer());
if (configuration.isAutoconfigure()) {
this.compilerAutoConfigurations = ServiceLoader
.load(CompilerAutoConfiguration.class);
}
else {
this.compilerAutoConfigurations = Collections.emptySet();
}
this.transformations = new ArrayList<ASTTransformation>();
this.transformations
.add(new DependencyManagementBomTransformation(resolutionContext));
this.transformations.add(new DependencyAutoConfigurationTransformation(
this.loader, resolutionContext, this.compilerAutoConfigurations));
this.transformations.add(new GroovyBeansTransformation());
if (this.configuration.isGuessDependencies()) {
this.transformations.add(
new ResolveDependencyCoordinatesTransformation(resolutionContext));
}
for (ASTTransformation transformation : ServiceLoader
.load(SpringBootAstTransformation.class)) {
this.transformations.add(transformation);
}
Collections.sort(this.transformations, AnnotationAwareOrderComparator.INSTANCE);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:43,代码来源:GroovyCompiler.java
示例3: processConversionOperations
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
private void processConversionOperations(LinkedList conversionOperations) {
int index = getIndexOfASTTransformationVisitor(conversionOperations);
conversionOperations.add(index, new CompilationUnit.SourceUnitOperation() {
@Override
public void call(SourceUnit source) throws CompilationFailedException {
ASTNode[] nodes = new ASTNode[] { source.getAST() };
for (ASTTransformation transformation : GroovyCompiler.this.transformations) {
transformation.visit(nodes, source);
}
}
});
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:GroovyCompiler.java
示例4: addTransform
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的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);
}
示例5: getTransformInstances
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
private Map<CompilePhase, Map<Class<? extends ASTTransformation>, Set<ASTNode>>> getTransformInstances() {
if(transformInstances == null){
transformInstances = new EnumMap<CompilePhase, Map<Class <? extends ASTTransformation>, Set<ASTNode>>>(CompilePhase.class);
for (CompilePhase phase : CompilePhase.values()) {
transformInstances.put(phase, new LinkedHashMap<Class <? extends ASTTransformation>, Set<ASTNode>>());
}
}
return transformInstances;
}
示例6: visitAnnotationsOnNode
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的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);
}
}
示例7: addTransform
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
@Override
public void addTransform(final Class<? extends ASTTransformation> transform, final ASTNode node) {
throw new UnsupportedOperationException();
}
示例8: getTransforms
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
public Map<Class <? extends ASTTransformation>, Set<ASTNode>> getTransforms(CompilePhase phase) {
return getTransformInstances().get(phase);
}
示例9: getAstTransformations
import org.codehaus.groovy.transform.ASTTransformation; //导入依赖的package包/类
/**
* Return a mutable list of the {@link ASTTransformation}s to be applied during
* {@link #compile(String...)}.
* @return the AST transformations to apply
*/
public List<ASTTransformation> getAstTransformations() {
return this.transformations;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:9,代码来源:GroovyCompiler.java