• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompilationCustomizer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.codehaus.groovy.control.customizers.CompilationCustomizer的典型用法代码示例。如果您正苦于以下问题:Java CompilationCustomizer类的具体用法?Java CompilationCustomizer怎么用?Java CompilationCustomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompilationCustomizer类属于org.codehaus.groovy.control.customizers包,在下文中一共展示了CompilationCustomizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: postCompleteNode

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
public Object postCompleteNode(final FactoryBuilderSupport factory, final Object parent, final Object node) {
    if (node instanceof Map) {
        Map map = (Map) node;
        ProxyGeneratorAdapter adapter = new ProxyGeneratorAdapter(
                map,
                map.containsKey("superClass")?(Class)map.get("superClass"):CompilationCustomizer.class,
                map.containsKey("interfaces")?(Class[])map.get("interfaces"):null,
                this.getClass().getClassLoader(),
                false,
                null
        );
        Object phase = map.get("phase");
        if (!(phase instanceof CompilePhase)) {
            phase = CompilePhase.valueOf(phase.toString());
        }
        return adapter.proxy(map, phase);
    }
    return node;
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:InlinedASTCustomizerFactory.java


示例2: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final org.codehaus.groovy.control.customizers.ImportCustomizer ic = new org.codehaus.groovy.control.customizers.ImportCustomizer();

    // there's something weird in groovy about doing specific imports instead of wildcard imports. with wildcard
    // imports groovy seems to allow methods to be overloaded with enums such that things like Column.values and
    // __.values() can be resolved by the compiler. if they are both directly in the imports then one or the other
    // can't be found. the temporary fix is to hardcode a wildcard import __ and then filter out the core imports
    // from the incoming customizer. ultimately, the fix should be to resolve the naming conflicts to ensure a
    // unique space somehow.
    ic.addStaticStars(__.class.getCanonicalName());
    for (ImportCustomizer customizer : customizers) {
        customizer.getClassImports().forEach(i -> ic.addImports(i.getCanonicalName()));
        customizer.getMethodImports().stream()
                .filter(m -> !m.getDeclaringClass().equals(__.class))
                .forEach(m -> ic.addStaticImport(m.getDeclaringClass().getCanonicalName(), m.getName()));
        customizer.getEnumImports().forEach(m -> ic.addStaticImport(m.getDeclaringClass().getCanonicalName(), m.name()));
    }

    return ic;
}
 
开发者ID:apache,项目名称:tinkerpop,代码行数:22,代码来源:ImportGroovyCustomizer.java


示例3: compile

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public Set<Class<?>> compile(ScriptArchive archive, JBossModuleClassLoader moduleClassLoader, Path compilationRootDir)
    throws ScriptCompilationException, IOException {
    
    List<CompilationCustomizer> customizers = new LinkedList<CompilationCustomizer>();

    for (String klassName: this.customizerClassNames) {
        CompilationCustomizer instance = this.getCustomizerInstanceFromString(klassName, moduleClassLoader);
        if (instance != null ) {
            customizers.add(instance);
        }
    }

    CompilerConfiguration config = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
    config.addCompilationCustomizers(customizers.toArray(new CompilationCustomizer[0]));

     new Groovy2CompilerHelper(compilationRootDir)
        .addScriptArchive(archive)
        .withParentClassloader(moduleClassLoader) // TODO: replace JBossModuleClassLoader with generic class loader
        .withConfiguration(config)
        .compile();
    return Collections.emptySet();
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:24,代码来源:Groovy2Compiler.java


示例4: testCompile

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Test
public void testCompile() throws Exception {
    Groovy2Compiler compiler;
    List<CompilationCustomizer> customizers;
    Map<String, Object> compilerParams;

    Path scriptRootPath = GroovyTestResourceUtil.findRootPathForScript(TestScript.HELLO_WORLD);
    PathScriptArchive scriptArchive = new PathScriptArchive.Builder(scriptRootPath)
        .setRecurseRoot(false)
        .addFile(TestScript.HELLO_WORLD.getScriptPath())
        .build();

    compilerParams = new HashMap<String, Object>();
    compilerParams.put(Groovy2Compiler.GROOVY2_COMPILER_PARAMS_CUSTOMIZERS, Arrays.asList(new Object[] {"testmodule.customizers.TestCompilationCustomizer"}));

    compiler = new Groovy2Compiler(compilerParams);
    compiler.compile(scriptArchive, null, scriptRootPath);
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:19,代码来源:Groovy2CompilerTest.java


示例5: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final ImportCustomizer ic = new ImportCustomizer();

    processImports(ic, imports);
    processStaticImports(ic, staticImports);
    processImports(ic, extraImports);
    processStaticImports(ic, extraStaticImports);

    return ic;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:AbstractImportCustomizerProvider.java


示例6: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final Map<String, Object> timedInterruptAnnotationParams = new HashMap<>();
    timedInterruptAnnotationParams.put("value", interruptionTimeout);
    timedInterruptAnnotationParams.put("unit", GeneralUtils.propX(GeneralUtils.classX(TimeUnit.class), TimeUnit.MILLISECONDS.toString()));
    timedInterruptAnnotationParams.put("checkOnMethodStart", false);
    timedInterruptAnnotationParams.put("thrown", GeneralUtils.classX(TimedInterruptTimeoutException.class));
    return new ASTTransformationCustomizer(timedInterruptAnnotationParams, TimedInterrupt.class);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:TimedInterruptCustomizerProvider.java


示例7: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final Map<String, Object> annotationParams = new HashMap<>();
    if (extensions != null && !extensions.isEmpty()) {
        if (extensions.contains(","))
            annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList()));
        else
            annotationParams.put("extensions", Collections.singletonList(extensions));
    }
    return new ASTTransformationCustomizer(annotationParams, TypeChecked.class);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:12,代码来源:TypeCheckedCustomizerProvider.java


示例8: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final Map<String, Object> annotationParams = new HashMap<>();
    if (extensions != null && !extensions.isEmpty()) {
        if (extensions.contains(","))
            annotationParams.put("extensions", Stream.of(extensions.split(",")).collect(Collectors.toList()));
        else
            annotationParams.put("extensions", Collections.singletonList(extensions));
    }

    return new ASTTransformationCustomizer(annotationParams, CompileStatic.class);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:CompileStaticCustomizerProvider.java


示例9: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    final ImportCustomizer ic = new ImportCustomizer();

    processImports(ic, extraImports);
    processStaticImports(ic, extraStaticImports);

    return ic;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:10,代码来源:EmptyImportCustomizerProvider.java


示例10: MarkupTemplateEngine

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
public MarkupTemplateEngine(final ClassLoader parentLoader, final TemplateConfiguration tplConfig, final TemplateResolver resolver) {
    compilerConfiguration = new CompilerConfiguration();
    templateConfiguration = tplConfig;
    compilerConfiguration.addCompilationCustomizers(new TemplateASTTransformer(tplConfig));
    compilerConfiguration.addCompilationCustomizers(
            new ASTTransformationCustomizer(Collections.singletonMap("extensions", "groovy.text.markup.MarkupTemplateTypeCheckingExtension"), CompileStatic.class));
    if (templateConfiguration.isAutoNewLine()) {
        compilerConfiguration.addCompilationCustomizers(
                new CompilationCustomizer(CompilePhase.CONVERSION) {
                    @Override
                    public void call(final SourceUnit source, final GeneratorContext context, final ClassNode classNode) throws CompilationFailedException {
                        new AutoNewLineTransformer(source).visitClass(classNode);
                    }
                }
        );
    }
    groovyClassLoader = AccessController.doPrivileged(new PrivilegedAction<TemplateGroovyClassLoader>() {
        public TemplateGroovyClassLoader run() {
            return new TemplateGroovyClassLoader(parentLoader, compilerConfiguration);
        }
    });
    if (DEBUG_BYTECODE) {
        compilerConfiguration.setBytecodePostprocessor(BytecodeDumper.STANDARD_ERR);
    }
    templateResolver = resolver == null ? new DefaultTemplateResolver() : resolver;
    templateResolver.configure(groovyClassLoader, templateConfiguration);
}
 
开发者ID:apache,项目名称:groovy,代码行数:28,代码来源:MarkupTemplateEngine.java


示例11: setChild

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void setChild(final FactoryBuilderSupport builder, final Object parent, final Object child) {
    if (parent instanceof Collection && child instanceof CompilationCustomizer) {
        ((Collection) parent).add(child);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:CustomizersFactory.java


示例12: postCompleteNode

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Object postCompleteNode(final FactoryBuilderSupport factory, final Object parent, final Object node) {
    if (node instanceof List) {
        List col = (List) node;
        return col.toArray(new CompilationCustomizer[col.size()]);
    }
    return node;
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:CustomizersFactory.java


示例13: newInstance

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
public Object newInstance(final FactoryBuilderSupport builder, final Object name, final Object value, final Map attributes) throws InstantiationException, IllegalAccessException {
    SourceOptions data = new SourceOptions();
    if (value instanceof CompilationCustomizer) {
        data.delegate = (CompilationCustomizer) value;
    }
    return data;
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:SourceAwareCustomizerFactory.java


示例14: Workspace

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
public Workspace(WorkspaceService workspaceService, String name) {
    this.workspaceService = workspaceService;
    this.name = name;
    File autorunDirectory = workspaceService.getAutorunDirectory();
    autorunFile = new File(autorunDirectory, name+".groovy");
    this.autorunDirectory = new File(autorunDirectory, name);
    compilerConfiguration = new CompilerConfiguration();
    compilerConfiguration.setScriptBaseClass(CallerScript.class.getName());
    List<CompilationCustomizer> compilationCustomizers = compilerConfiguration.getCompilationCustomizers();
    compilerConfiguration.getClasspath().addAll(workspaceService.getClassPath());
    String encoding = workspaceService.getVarScript().getConfig().getString("sources.encoding");
    if (encoding != null) compilerConfiguration.setSourceEncoding(encoding);
    compilationCustomizers.addAll(workspaceService.getCompilationCustomizers());
    groovyClassLoader = new GroovyClassLoader(workspaceService.getGroovyClassLoader(), compilerConfiguration);
}
 
开发者ID:DPOH-VAR,项目名称:VarScript,代码行数:16,代码来源:Workspace.java


示例15: testCustomiizerParamsProcessing

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testCustomiizerParamsProcessing() throws Exception {
    Groovy2Compiler compiler;
    List<CompilationCustomizer> customizers;
    Map<String, Object> compilerParams;

    Field f = Groovy2Compiler.class.getDeclaredField("customizerClassNames");
    f.setAccessible(true);

    // empty parameters map
    compiler = new Groovy2Compiler(new HashMap<String, Object>());
    customizers = (List<CompilationCustomizer>)f.get(compiler);
    assertTrue(customizers.size() == 0, "no valid objects expected");

    // null value customizers parameter
    compilerParams = new HashMap<String, Object>();
    compilerParams.put(Groovy2Compiler.GROOVY2_COMPILER_PARAMS_CUSTOMIZERS, null);

    compiler = new Groovy2Compiler(compilerParams);
    customizers = (List)f.get(compiler);
    assertTrue(customizers.size() == 0, "no valid objects expected");

    // list with valid customizer
    compilerParams = new HashMap<String, Object>();
    compilerParams.put(Groovy2Compiler.GROOVY2_COMPILER_PARAMS_CUSTOMIZERS, Arrays.asList(new String[] {"org.codehaus.groovy.control.customizers.ImportCustomizer"}));

    compiler = new Groovy2Compiler(compilerParams);
    customizers = (List)f.get(compiler);
    assertTrue(customizers.size() == 1, "one valid object expected");

    // list with invalid objects
    compilerParams = new HashMap<String, Object>();
    compilerParams.put(Groovy2Compiler.GROOVY2_COMPILER_PARAMS_CUSTOMIZERS, Arrays.asList(new Object[] {"org.codehaus.groovy.control.customizers.ImportCustomizer", "org.codehaus.groovy.control.customizers.ImportCustomizer", new HashMap<String, Object>(), null}));

    compiler = new Groovy2Compiler(compilerParams);
    customizers = (List)f.get(compiler);
    assertTrue(customizers.size() == 2, "two valid objects expected");
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:40,代码来源:Groovy2CompilerTest.java


示例16: addCompilationCustomizers

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
public void addCompilationCustomizers(CompilationCustomizer... customizers) {
	this.loader.getConfiguration().addCompilationCustomizers(customizers);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:4,代码来源:GroovyCompiler.java


示例17: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    return new ImportCustomizer();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:NoImportCustomizerProvider.java


示例18: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    throw new UnsupportedOperationException("This is a marker implementation that does not create a CompilationCustomizer instance");
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:ConfigurationCustomizerProvider.java


示例19: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    return new ASTTransformationCustomizer(ThreadInterrupt.class);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:ThreadInterruptCustomizerProvider.java


示例20: create

import org.codehaus.groovy.control.customizers.CompilationCustomizer; //导入依赖的package包/类
@Override
public CompilationCustomizer create() {
    return new ASTTransformationCustomizer(InterpreterMode.class);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:5,代码来源:InterpreterModeCustomizerProvider.java



注:本文中的org.codehaus.groovy.control.customizers.CompilationCustomizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VisitContext类代码示例发布时间:2022-05-22
下一篇:
Java ResourceInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap