SwiftGenerator { public void parse(Iterable<URI> inputs) throws Exception { Preconditions.checkArgument( inputs != null && inputs.iterator().hasNext(), "No input files!"); LOG.info("Parsing Thrift IDL from %s...", inputs); final Map<String, SwiftDocumentContext> contexts = Maps.newHashMap(); for (final URI inputUri : inputs) { parsedDocuments.clear(); parseDocument( inputUri.isAbsolute() ? inputUri : swiftGeneratorConfig.getInputBase().resolve(inputUri), contexts, new TypeRegistry(), new TypedefRegistry()); } LOG.info("IDL parsing complete, writing java code..."); for (final SwiftDocumentContext context : contexts.values()) { generateFiles(context); } LOG.info("Java code generation complete."); } SwiftGenerator(final SwiftGeneratorConfig swiftGeneratorConfig); void parse(Iterable<URI> inputs);  }
@Test(dataProvider = "thriftProvider") public void testGenerate(GenerationPaths paths) throws Exception { Path rootPath = getResourcePath(""); Path relativePath = rootPath.relativize(Paths.get(paths.getInputFile())); String testPath = relativePath.toString().replace( relativePath.getFileSystem().getSeparator(), "_"); File outputDirectory = new File(outputFolderRoot, testPath); File sourceDirectory = new File(outputDirectory, "source"); File classesDirectory = new File(outputDirectory, "classes"); final SwiftGeneratorConfig config = SwiftGeneratorConfig.builder() .inputBase(paths.getInputBase()) .includeSearchPaths(Arrays.asList(paths.getIncludeSearchPaths())) .outputFolder(sourceDirectory) .generateIncludedCode(true) .codeFlavor("java-immutable") .defaultPackage("com.facebook.swift") .addTweak(SwiftGeneratorTweak.ADD_CLOSEABLE_INTERFACE) .addTweak(SwiftGeneratorTweak.EXTEND_RUNTIME_EXCEPTION) .addTweak(SwiftGeneratorTweak.ADD_THRIFT_EXCEPTION) .addTweak(SwiftGeneratorTweak.USE_PLAIN_JAVA_NAMESPACE) .build(); final SwiftGenerator generator = new SwiftGenerator(config); generator.parse(Collections.singletonList(paths.getInputFile())); assertCompilation( sourceDirectory.toPath(), classesDirectory.toPath()); }