Package org.codehaus.groovy.control.customizers

Examples of org.codehaus.groovy.control.customizers.ImportCustomizer


        CompilerConfiguration compConfig = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
        properties = props;

        compConfig.setScriptBaseClass("org.grouplens.lenskit.eval.script.EvalScript");

        ImportCustomizer imports = new ImportCustomizer();
        imports.addStarImports("org.grouplens.lenskit",
                               "org.grouplens.lenskit.params",
                               "org.grouplens.lenskit.baseline",
                               "org.grouplens.lenskit.norm",
                               "org.grouplens.lenskit.eval.metrics.predict",
                               "org.grouplens.lenskit.eval.metrics.recommend");
View Full Code Here


    public ConfigurationLoader(ClassLoader loader) {
        classLoader = loader;
        binding = new Binding();
        CompilerConfiguration config = new CompilerConfiguration();
        config.setScriptBaseClass(LenskitConfigScript.class.getName());
        ImportCustomizer imports = new ImportCustomizer();
        imports.addStarImports("org.grouplens.lenskit");
        config.addCompilationCustomizers(imports);
        shell = new GroovyShell(loader, binding, config);
        directory = ClassDirectory.forClassLoader(loader);
    }
View Full Code Here

        if (configscript!=null) {
            Binding binding = new Binding();
            binding.setVariable("configuration", configuration);

            CompilerConfiguration configuratorConfig = new CompilerConfiguration();
            ImportCustomizer customizer = new ImportCustomizer();
            customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
            configuratorConfig.addCompilationCustomizers(customizer);

            GroovyShell shell = new GroovyShell(binding, configuratorConfig);
            File confSrc = new File(configscript);
            try {
View Full Code Here

            File groovyConfigurator = new File(path);
            Binding binding = new Binding();
            binding.setVariable("configuration", configuration);

            CompilerConfiguration configuratorConfig = new CompilerConfiguration();
            ImportCustomizer customizer = new ImportCustomizer();
            customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
            configuratorConfig.addCompilationCustomizers(customizer);

            GroovyShell shell = new GroovyShell(binding, configuratorConfig);
            shell.evaluate(groovyConfigurator);
        }
View Full Code Here

             File groovyConfigurator = new File(path);
             Binding binding = new Binding();
             binding.setVariable("configuration", main.conf);

             CompilerConfiguration configuratorConfig = new CompilerConfiguration();
             ImportCustomizer customizer = new ImportCustomizer();
             customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
             configuratorConfig.addCompilationCustomizers(customizer);

             GroovyShell shell = new GroovyShell(binding, configuratorConfig);
             shell.evaluate(groovyConfigurator);
         }
View Full Code Here

    public boolean isHandlesNodeChildren() {
        return true;
    }

    public Object newInstance(final FactoryBuilderSupport builder, final Object name, final Object value, final Map attributes) throws InstantiationException, IllegalAccessException {
        ImportCustomizer customizer = new ImportCustomizer();
        addImport(customizer, value);
        return customizer;
    }
View Full Code Here

    @Override
    public void setup() {
        CompilerConfiguration config = new CompilerConfiguration();
        config.setScriptBaseClass("org.codehaus.groovy.transform.stc.GroovyTypeCheckingExtensionSupport.TypeCheckingDSL");
        ImportCustomizer ic = new ImportCustomizer();
        ic.addStarImports("org.codehaus.groovy.ast.expr");
        ic.addStaticStars("org.codehaus.groovy.ast.ClassHelper");
        ic.addStaticStars("org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport");
        config.addCompilationCustomizers(ic);
        final GroovyClassLoader transformLoader = compilationUnit!=null?compilationUnit.getTransformLoader():typeCheckingVisitor.getSourceUnit().getClassLoader();

        // since Groovy 2.2, it is possible to use FQCN for type checking extension scripts
        TypeCheckingDSL script = null;
View Full Code Here

    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());
View Full Code Here

        ClassLoader cl = j != null ? j.getPluginManager().uberClassLoader : CpsGroovyShell.class.getClassLoader();
        return GroovySandbox.createSecureClassLoader(cl);
    }

    private static CompilerConfiguration makeConfig(CpsFlowExecution execution) {
        ImportCustomizer ic = new ImportCustomizer();
        ic.addStarImports(NonCPS.class.getPackage().getName());
        ic.addStarImports("hudson.model","jenkins.model");

        for (GroovyShellDecorator d : GroovyShellDecorator.all()) {
            d.customizeImports(execution,ic);
        }
View Full Code Here

    @Override
    public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
        throws CompilationFailedException {

      ImportCustomizer importCustomizer = new SmartImportCustomizer(source,
          context, classNode);
      ClassNode mainClassNode = getMainClass(source.getAST().getClasses());

      // Additional auto configuration
      for (CompilerAutoConfiguration autoConfiguration : GroovyCompiler.this.compilerAutoConfigurations) {
        if (autoConfiguration.matches(classNode)) {
          if (GroovyCompiler.this.configuration.isGuessImports()) {
            autoConfiguration.applyImports(importCustomizer);
            importCustomizer.call(source, context, classNode);
          }
          if (classNode.equals(mainClassNode)) {
            autoConfiguration.applyToMainClass(GroovyCompiler.this.loader,
                GroovyCompiler.this.configuration, context, source,
                classNode);
          }
          autoConfiguration
              .apply(GroovyCompiler.this.loader,
                  GroovyCompiler.this.configuration, context, source,
                  classNode);
        }
      }
      importCustomizer.call(source, context, classNode);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.control.customizers.ImportCustomizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.