public SpoonModelBuilder createCompiler(Factory factory, List<SpoonResource> inputSources) { SpoonModelBuilder c = createCompiler(factory); c.addInputSources(inputSources); return c; }
/** * 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; }
/** * 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; }
/** * 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(); }
/** 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); }
/** 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); }