Package org.codehaus.groovy.control

Examples of org.codehaus.groovy.control.CompilationUnit.addSource()


            // "." is used to transfer compilation dependencies, which will be
            // recollected later during compilation
            for (String depSourcePath : cache.get(".")) {
                try {
                    cache.get(depSourcePath);
                    cu.addSource(getResourceConnection(depSourcePath).getURL());
                } catch (ResourceException e) {
                    /* ignore */
                }
            }

View Full Code Here


                    };

                    final ClassLoader parent = theClass.getClassLoader();
                    CompilationUnit unit = new CompilationUnit();
                    unit.setClassgenCallback(search);
                    unit.addSource(url);
                    unit.compile(Phases.CLASS_GENERATION);
                }
                catch (Exception e) {
                    throw new GroovyRuntimeException("Exception thrown parsing: " + groovyFile + ". Reason: " + e, e);
                }
View Full Code Here

            String name = superClass.getName() + "$TraitAdapter";
            ClassNode cn = new ClassNode(name, ACC_PUBLIC | ACC_ABSTRACT, ClassHelper.OBJECT_TYPE, traits.toArray(new ClassNode[traits.size()]), null);
            CompilationUnit cu = new CompilationUnit(loader);
            CompilerConfiguration config = new CompilerConfiguration();
            SourceUnit su = new SourceUnit(name+"wrapper", "", config, loader, new ErrorCollector(config));
            cu.addSource(su);
            cu.compile(Phases.CONVERSION);
            su.getAST().addClass(cn);
            cu.compile(Phases.CLASS_GENERATION);
            @SuppressWarnings("unchecked")
            List<GroovyClass> classes = (List<GroovyClass>) cu.getClasses();
View Full Code Here

                final List<GroovyClass> groovyClassesForThisTemplate = new ArrayList<GroovyClass>();
                // ~~~ Please !
                CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
                compilerConfiguration.setSourceEncoding("utf-8"); // ouf
                CompilationUnit compilationUnit = new CompilationUnit(compilerConfiguration);
                compilationUnit.addSource(new SourceUnit(name, compiledSource, compilerConfiguration, tClassLoader, compilationUnit.getErrorCollector()));
                Field phasesF = compilationUnit.getClass().getDeclaredField("phaseOperations");
                phasesF.setAccessible(true);
                LinkedList[] phases = (LinkedList[]) phasesF.get(compilationUnit);
                LinkedList<GroovyClassOperation> output = new LinkedList<GroovyClassOperation>();
                phases[Phases.OUTPUT] = output;
View Full Code Here

    compilationUnit.setClassgenCallback(collector);

    for (String source : sources) {
      List<String> paths = ResourceUtils.getUrls(source, this.loader);
      for (String path : paths) {
        compilationUnit.addSource(new URL(path));
      }
    }

    addAstTransformations(compilationUnit);
View Full Code Here

    */
  
    public void compile( File file ) throws CompilationFailedException
    {
        CompilationUnit unit = new CompilationUnit( configuration );
        unit.addSource( file );
        unit.compile();
    }
   
   
   
View Full Code Here

    */
   
    public void compile( String name, String code ) throws CompilationFailedException
    {
        CompilationUnit unit = new CompilationUnit( configuration );
        unit.addSource( new SourceUnit(name, code, configuration, unit.getClassLoader(), unit.getErrorCollector()) );
        unit.compile();
    }

}

View Full Code Here

                for (int j=0; j < includes.length; j++) {
                    File file = new File(basedir, includes[j]);
                    log.debug("    "  + file);

                    compilation.addSource(file);
                    count++;
                }
            }
            else {
                log.debug("Including changed files from: " + basedir);
View Full Code Here

                File[] files = sourceScanner.restrictAsFiles(includes, basedir, destdir, mapper);

                for (int j=0; j < files.length; j++) {
                    log.debug("    "  + files[j]);

                    compilation.addSource(files[j]);
                    count++;
                }
            }
        }
View Full Code Here

                    };

                    final ClassLoader parent = theClass.getClassLoader();
                    CompilationUnit unit = new CompilationUnit();
                    unit.setClassgenCallback(search);
                    unit.addSource(url);
                    unit.compile(Phases.CLASS_GENERATION);
                }
                catch (Exception e) {
                    throw new GroovyRuntimeException("Exception thrown parsing: " + groovyFile + ". Reason: " + e, e);
                }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.