Package org.codehaus.groovy.control

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


   
    ClassCollector collector = new ClassCollector();
    unit.setClassgenCallback(collector);
    try
    {
      unit.compile(Phases.CLASS_GENERATION);
    }
    catch (CompilationFailedException e)
    {
      throw new JRException(
        "Errors were encountered when compiling report expressions class file:\n"
View Full Code Here


       
        final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();

        try {
            log.debug("compiling");
            unit.compile(Phases.CLASS_GENERATION);
           
            @SuppressWarnings("unchecked") // Groovy library is not yet generic
            final List<GroovyClass> classes = unit.getClasses();
            for (GroovyClass clazz : classes) {
                final byte[] bytes = clazz.getBytes();
View Full Code Here

                        }
                    });
                    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

                        }
                    });
                    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

                        }
                    });
                    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

    public ModuleNode getAST(String source, int untilPhase) {
        SourceUnit unit = SourceUnit.create("Test", source);
        CompilationUnit compUnit = new CompilationUnit();
        compUnit.addSource(unit);
        compUnit.compile(untilPhase);
        return unit.getAST();
    }

    public ModuleNode getAST(String source) {
        return getAST(source, Phases.SEMANTIC_ANALYSIS);
View Full Code Here

                        }
                    });
                    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

               for (int i = 0; i < files.length; i++)
                  cunit.addSource(files[i].getPath());
            }
            SingleClassCollector collector = createSingleCollector(cunit, targetSunit);
            cunit.setClassgenCallback(collector);
            cunit.compile(phase);

            for (Iterator iter = collector.getLoadedClasses().iterator(); iter.hasNext();)
            {
               Class clazz = (Class)iter.next();
               String classname = clazz.getName();
View Full Code Here

         Set<SourceUnit> setSunit = new HashSet<SourceUnit>();
         for (int i = 0; i < sources.length; i++)
            setSunit.add(cunit.addSource(sources[i].getPath()));
         MultipleClassCollector collector = createMultipleCollector(cunit, setSunit);
         cunit.setClassgenCallback(collector);
         cunit.compile(phase);

         for (Iterator iter = collector.getLoadedClasses().iterator(); iter.hasNext();)
         {
            Class clazz = (Class)iter.next();
            String classname = clazz.getName();
View Full Code Here

                        }
                    });
                    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.