本文整理汇总了Java中org.codehaus.groovy.control.CompilerConfiguration.DEFAULT属性的典型用法代码示例。如果您正苦于以下问题:Java CompilerConfiguration.DEFAULT属性的具体用法?Java CompilerConfiguration.DEFAULT怎么用?Java CompilerConfiguration.DEFAULT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.codehaus.groovy.control.CompilerConfiguration
的用法示例。
在下文中一共展示了CompilerConfiguration.DEFAULT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GroovyCodeBlockCompiler
private GroovyCodeBlockCompiler() {
CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
ImportCustomizer imports = new ImportCustomizer();
imports.addStarImports("org.voltdb");
imports.addImports(
"org.voltdb.groovy.TableBuilder",
"org.voltdb.groovy.Tuplerator",
"org.voltdb.VoltProcedure.VoltAbortException"
);
imports.addStaticStars("org.voltdb.VoltProcedure","org.voltdb.VoltType");
conf.addCompilationCustomizers(imports);
// conf.getOptimizationOptions().put("int", false);
// conf.getOptimizationOptions().put("indy", true);
conf.setScriptBaseClass(DelegatingScript.class.getName());
File groovyOut = createGroovyOutDirectory();
List<String> classPath = conf.getClasspath();
classPath.add(groovyOut.getAbsolutePath());
conf.setClasspathList(classPath);
conf.setTargetDirectory(groovyOut);
gcl = new GroovyClassLoader(Thread.currentThread().getContextClassLoader(), conf);
}
示例2: getCompilerConfiguration
@Override
protected CompilerConfiguration getCompilerConfiguration() {
CompilerConfiguration configuration = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
configuration.setPluginFactory(new Antlr4PluginFactory());
return configuration;
}
示例3: GroovyClassLoader
/**
* creates a GroovyClassLoader.
*
* @param parent the parent class loader
* @param config the compiler configuration
* @param useConfigurationClasspath determines if the configurations classpath should be added
*/
public GroovyClassLoader(ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath) {
super(EMPTY_URL_ARRAY, parent);
if (config == null) config = CompilerConfiguration.DEFAULT;
this.config = config;
if (useConfigurationClasspath) {
for (String path : config.getClasspath()) {
this.addClasspath(path);
}
}
initSourceEncoding(config);
}
示例4: doParseClass
private Class doParseClass(GroovyCodeSource codeSource) {
validate(codeSource);
Class answer; // Was neither already loaded nor compiling, so compile and add to cache.
CompilerConfiguration config = CompilerConfiguration.DEFAULT;
CompilationUnit unit = createCompilationUnit(config, codeSource.getCodeSource());
SourceUnit su = null;
if (codeSource.getFile() == null) {
su = unit.addSource(codeSource.getName(), codeSource.getScriptText());
}
else {
su = unit.addSource(codeSource.getFile());
}
MyClassCollector collector = createMyCollector(unit, su);
unit.setClassgenCallback(collector);
int goalPhase = Phases.CLASS_GENERATION;
if (config != null && config.getTargetDirectory() != null)
goalPhase = Phases.OUTPUT;
unit.compile(goalPhase);
@SuppressWarnings("unchecked")
List<Class<?>> classList = (List<Class<?>>) collector.getLoadedClasses();
answer = classList.get(0);
String mainClass = su.getAST().getMainClassName();
for (Object o : collector.getLoadedClasses()) {
Class clazz = (Class) o;
String clazzName = clazz.getName();
definePackage(clazzName);
setClassCacheEntry(clazz);
if (clazzName.equals(mainClass))
answer = clazz;
}
synchronized (classBytes) {
this.classBytes.put(resolveName(answer.getName()) + ".class", collector.code);
}
return answer;
}
示例5: createClassLoader
private synchronized void createClassLoader() {
final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
conf.addCompilationCustomizers(this.importGroovyCustomizer.create());
// ConfigurationCustomizerProvider is treated separately
groovyCustomizers.stream().filter(cp -> !(cp instanceof ConfigurationGroovyCustomizer))
.forEach(p -> conf.addCompilationCustomizers(p.create()));
groovyCustomizers.stream().filter(cp -> cp instanceof ConfigurationGroovyCustomizer).findFirst()
.ifPresent(cp -> ((ConfigurationGroovyCustomizer) cp).applyCustomization(conf));
this.loader = new GremlinGroovyClassLoader(getParentLoader(), conf);
}
示例6: prepareCompilerConfiguration
protected CompilerConfiguration prepareCompilerConfiguration() {
return new CompilerConfiguration(CompilerConfiguration.DEFAULT);
}
示例7: getCompilerConfiguration
@Override
protected CompilerConfiguration getCompilerConfiguration() {
return CompilerConfiguration.DEFAULT;
}
示例8: GroovyShell
public GroovyShell(ClassLoader parent, Binding binding) {
this(parent, binding, CompilerConfiguration.DEFAULT);
}