use of org.codehaus.groovy.control.customizers.ASTTransformationCustomizer in project groovity by disney.
the class Groovity method createCompilerConfiguration.
protected CompilerConfiguration createCompilerConfiguration(Map<Integer, Integer> sourceLineNumbers, Collection<String> initDependencies) {
CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
if (scriptBaseClass != null) {
compilerConfiguration.setScriptBaseClass(scriptBaseClass);
compilerConfiguration.addCompilationCustomizers(new ImportCustomizer().addImports(scriptBaseClass));
}
compilerConfiguration.addCompilationCustomizers(new ImportCustomizer().addStarImports("java.util.concurrent", "groovy.transform", "java.util.function", "com.disney.groovity.model").addImports(ClosureWritable.class.getName(), AsyncChannel.class.getName(), GroovityStatistics.class.getName(), Taggable.class.getName(), Tag.class.getName(), Attr.class.getName(), Function.class.getName(), Arg.class.getName(), SkipStatistics.class.getName()));
compilerConfiguration.addCompilationCustomizers(new ASTTransformationCustomizer(new GroovityASTTransformation(this, sourceLineNumbers, initDependencies)));
compilerConfiguration.addCompilationCustomizers(new ASTTransformationCustomizer(new StatsASTTransformation()));
Map<String, Boolean> options = compilerConfiguration.getOptimizationOptions();
options.put(CompilerConfiguration.JDK8, true);
compilerConfigurationDecorators.forEach(decorator -> {
decorator.decorate(compilerConfiguration);
});
return compilerConfiguration;
}
use of org.codehaus.groovy.control.customizers.ASTTransformationCustomizer in project spring-integration by spring-projects.
the class GroovyScriptExecutingMessageProcessor method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (this.beanFactory != null && this.beanFactory instanceof ConfigurableListableBeanFactory) {
((ConfigurableListableBeanFactory) this.beanFactory).ignoreDependencyType(MetaClass.class);
}
CompilerConfiguration compilerConfiguration = this.compilerConfiguration;
if (compilerConfiguration == null && this.compileStatic) {
compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.addCompilationCustomizers(new ASTTransformationCustomizer(CompileStatic.class));
}
this.groovyClassLoader = new GroovyClassLoader(this.beanClassLoader, compilerConfiguration);
}
use of org.codehaus.groovy.control.customizers.ASTTransformationCustomizer in project RecordManager2 by moravianlibrary.
the class AbstractScriptFactory method innerCreate.
private MappingScript<T> innerCreate(List<byte[]> scriptsSource) {
logger.info("About to create new mapping script");
final AssignmentEliminationTransformation astTransformer = new AssignmentEliminationTransformation();
final Binding binding = createBinding();
final List<DelegatingScript> scripts = new ArrayList<DelegatingScript>(scriptsSource.size());
final CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
compilerConfiguration.setScriptBaseClass(DelegatingScript.class.getCanonicalName());
compilerConfiguration.addCompilationCustomizers(new SecureASTCustomizer(), new ASTTransformationCustomizer(astTransformer));
for (byte[] scriptSource : scriptsSource) {
GroovyShell sh = new GroovyShell(binding, compilerConfiguration);
final DelegatingScript script = (DelegatingScript) sh.parse(new InputStreamReader(new ByteArrayInputStream(scriptSource)));
scripts.add(script);
astTransformer.getVariablesToExclude().addAll(astTransformer.getVariablesToExclude());
}
Collections.reverse(scripts);
MappingScript<T> result = create(binding, scripts);
logger.info("New mapping script created");
return result;
}
Aggregations