Пример #1
0
 private static void write(ContextFactory factory, SourceFile file) {
   try {
     RuntimeModel model = factory.create(file.getInputPath()).getModel();
     String source = generator.generate(file, model);
     Files.createDirectories(file.getOutputPath().getParent());
     Files.write(
         file.getOutputPath(),
         source.getBytes(Charset.forName("UTF-8")),
         StandardOpenOption.CREATE,
         StandardOpenOption.TRUNCATE_EXISTING);
   } catch (Throwable t) {
     throw new CodeGeneratorException(t);
   }
 }
Пример #2
0
 public String generate(Path path) {
   ContextFactory factory = ContextFactoryScanner.get(path);
   SourceFile sourceFile = new SourceFile(path);
   return generate(sourceFile, factory.create(path).getModel());
 }