@Override public SpoonModelBuilder createCompiler() { return createCompiler(factory); }
/** * Creates a new Spoon Java compiler with a default factory and a list of * input sources. */ public SpoonModelBuilder createCompiler(List<SpoonResource> inputSources) { SpoonModelBuilder c = createCompiler(factory); c.addInputSources(inputSources); return c; }
public SpoonModelBuilder createCompiler(Factory factory, List<SpoonResource> inputSources) { SpoonModelBuilder c = createCompiler(factory); c.addInputSources(inputSources); return c; }
/** * Creates a new Spoon Java compiler in order to process and compile Java * source code. */ public SpoonModelBuilder createCompiler(Factory factory, List<SpoonResource> inputSources, List<SpoonResource> templateSources) { SpoonModelBuilder c = createCompiler(factory); c.addInputSources(inputSources); c.addTemplateSources(templateSources); return c; }
public static void process(Factory factory, Collection<Processor<?>> processors) { final JDTBasedSpoonCompiler compiler = (JDTBasedSpoonCompiler) new Launcher().createCompiler(factory); compiler.process(processors); }
/** * Utility method for testing: creates the model of the given `classesToBuild` from src/test/java and returns the factory * and allows to configure the Launcher first using `config` */ public static Factory build(Consumer<Launcher> config, Class<?>... classesToBuild) throws Exception { final Launcher launcher = new Launcher(); config.accept(launcher); SpoonModelBuilder comp = launcher.createCompiler(); for (Class<?> classToBuild : classesToBuild) { comp.addInputSources(SpoonResourceHelper.resources("./src/test/java/" + classToBuild.getName().replace('.', '/') + ".java")); } comp.build(); return comp.getFactory(); }
/** checks that the file `outputDirectoryFile` can be parsed with Spoon , given a compliance level and the noclasspath option. */ public static void canBeBuilt(File outputDirectoryFile, int complianceLevel, boolean noClasspath) { final Launcher launcher = new Launcher(); final Factory factory = launcher.getFactory(); factory.getEnvironment().setComplianceLevel(complianceLevel); factory.getEnvironment().setNoClasspath(noClasspath); final SpoonModelBuilder compiler = launcher.createCompiler(factory); compiler.addInputSource(outputDirectoryFile); try { compiler.build(); } catch (Exception e) { final AssertionError error = new AssertionError("Can't compile " + outputDirectoryFile.getName() + " because " + e.getMessage()); error.initCause(e); throw error; } }
/** Utility method for testing: creates the model of `packageName` and the factory from src/test/java and returns the CtType corresponding to `className` */ public static <T extends CtType<?>> T build(String packageName, String className, final Factory f) throws Exception { Launcher launcher = new Launcher() { @Override public Factory createFactory() { return f; } }; SpoonModelBuilder comp = launcher.createCompiler(); comp.addInputSources(SpoonResourceHelper.resources("./src/test/java/" + packageName.replace('.', '/') + "/" + className + ".java")); comp.build(); return comp.getFactory().Package().get(packageName).getType(className); }
/** Builds the Spoon mode of the `filesToBuild` given as parameter */ public static Factory build(File... filesToBuild) { final Launcher launcher = new Launcher(); launcher.getEnvironment().setNoClasspath(true); SpoonModelBuilder comp = launcher.createCompiler(); for (File fileToBuild : filesToBuild) { try { comp.addInputSource(SpoonResourceHelper.createResource(fileToBuild)); } catch (FileNotFoundException e) { throw new RuntimeException("File not found", e); } } comp.build(); return comp.getFactory(); }
/** Utility method for testing: creates the model of `packageName` from src/test/java and returns the CtType corresponding to `className` */ public static <T extends CtType<?>> T build(String packageName, String className) throws Exception { Launcher launcher = new Launcher(); launcher.getEnvironment().setCommentEnabled(false); // we don't want to parse the comments for equals SpoonModelBuilder comp = launcher.createCompiler(); comp.addInputSources(SpoonResourceHelper.resources("./src/test/java/" + packageName.replace('.', '/') + "/" + className + ".java")); comp.build(); return comp.getFactory().Package().get(packageName).getType(className); }
@Override public SpoonCompiler createCompiler() { return createCompiler(factory); }
modelBuilder = createCompiler();
/** * Creates a new Spoon Java compiler with a default factory and a list of * input sources. */ public SpoonCompiler createCompiler(List<SpoonResource> inputSources) { SpoonCompiler c = createCompiler(factory); c.addInputSources(inputSources); return c; }
public SpoonCompiler createCompiler(Factory factory, List<SpoonResource> inputSources) { SpoonCompiler c = createCompiler(factory); c.addInputSources(inputSources); return c; }
/** * Creates a new Spoon Java compiler in order to process and compile Java * source code. */ public SpoonCompiler createCompiler(Factory factory, List<SpoonResource> inputSources, List<SpoonResource> templateSources) { SpoonCompiler c = createCompiler(factory); c.addInputSources(inputSources); c.addTemplateSources(templateSources); return c; }
public static TestListener runTest(Configuration configuration, Launcher launcher, String failingTestClass, String failingTestMethod) { final SpoonModelBuilder compiler = launcher.createCompiler(); compiler.setBinaryOutputDirectory(new File(configuration.getBinaryOutputDirectory())); compiler.compile(SpoonModelBuilder.InputType.CTTYPES); try { return EntryPoint.runTests( configuration.getBinaryOutputDirectory() + Util.PATH_SEPARATOR + configuration.getClasspath(), failingTestClass, failingTestMethod ); } catch (TimeoutException e) { throw new RuntimeException(e); } }
final SpoonModelBuilder compiler = spoon.createCompiler();
public static Factory modelFor(Factory factory, File[] sourceFiles, URL[] classpath) { factory.getEnvironment().setLevel("OFF"); factory.getEnvironment().setCommentEnabled(false); SpoonModelBuilder compiler = launcher().createCompiler(factory); if (classpath != null) { compiler.setSourceClasspath(JavaLibrary.asFilePath(classpath)); } for (int i = 0; i < sourceFiles.length; i++) { File sourceFile = sourceFiles[i]; compiler.addInputSource(sourceFile); } compiler.build(); return factory; }
SpoonModelBuilder compiler = spoon.createCompiler(); compiler.setBinaryOutputDirectory(new File(configuration.getBinaryOutputDirectory())); compiler.compile(SpoonModelBuilder.InputType.CTTYPES);
modelBuilder = createCompiler();