use of edu.princeton.cs.algs4.ST in project che by eclipse.
the class TypeScriptDtoGenerator method execute.
/**
* Execute this generator.
*/
public String execute() {
init();
ST template = getTemplate();
template.add("dtos", this.dtoModels);
String output = template.render();
return output;
}
use of edu.princeton.cs.algs4.ST in project buck by facebook.
the class StringTemplateStep method execute.
@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
String template;
try {
template = new String(Files.readAllBytes(templatePath), Charsets.UTF_8);
} catch (IOException e) {
context.logError(e, "Could not read sh_binary template file");
return StepExecutionResult.ERROR;
}
ST st = new ST(template);
return new WriteFileStep(filesystem, Preconditions.checkNotNull(configure.apply(st).render()), outputPath, /* executable */
false).execute(context);
}
use of edu.princeton.cs.algs4.ST in project buck by facebook.
the class IjProjectWriter method writeGeneratedByIdeaClassToFile.
private void writeGeneratedByIdeaClassToFile(IjModuleAndroidFacet androidFacet, IJProjectCleaner cleaner, String packageName, String className, @Nullable String content) throws IOException {
ST contents = getST(StringTemplateFile.GENERATED_BY_IDEA_CLASS).add("package", packageName).add("className", className).add("content", content);
Path fileToWrite = androidFacet.getGeneratedSourcePath().resolve(packageName.replace(".", "/")).resolve(className + ".java");
cleaner.doNotDelete(fileToWrite);
writeToFile(contents, fileToWrite);
}
use of edu.princeton.cs.algs4.ST in project buck by facebook.
the class IjProjectWriter method writeLibrary.
private Path writeLibrary(IjLibrary library) throws IOException {
projectFilesystem.mkdirs(LIBRARIES_PREFIX);
Path path = LIBRARIES_PREFIX.resolve(library.getName() + ".xml");
ST contents = getST(StringTemplateFile.LIBRARY_TEMPLATE);
contents.add("name", library.getName());
contents.add("binaryJar", library.getBinaryJar().map(MorePaths::pathWithUnixSeparators).orElse(null));
contents.add("classPaths", library.getClassPaths().stream().map(MorePaths::pathWithUnixSeparators).collect(MoreCollectors.toImmutableSet()));
contents.add("sourceJar", library.getSourceJar().map(MorePaths::pathWithUnixSeparators).orElse(null));
contents.add("javadocUrl", library.getJavadocUrl().orElse(null));
//TODO(marcinkosiba): support res and assets for aar.
writeToFile(contents, path);
return path;
}
use of edu.princeton.cs.algs4.ST in project buck by facebook.
the class IjProjectWriter method writeModule.
private Path writeModule(IjModule module) throws IOException {
projectFilesystem.mkdirs(MODULES_PREFIX);
Path path = module.getModuleImlFilePath();
ST moduleContents = getST(StringTemplateFile.MODULE_TEMPLATE);
moduleContents.add("contentRoot", projectDataPreparer.getContentRoot(module));
moduleContents.add("dependencies", projectDataPreparer.getDependencies(module));
moduleContents.add("generatedSourceFolders", projectDataPreparer.getGeneratedSourceFolders(module));
moduleContents.add("androidFacet", projectDataPreparer.getAndroidProperties(module));
moduleContents.add("sdk", module.getSdkName().orElse(null));
moduleContents.add("sdkType", module.getSdkType().orElse(null));
moduleContents.add("languageLevel", JavaLanguageLevelHelper.convertLanguageLevelToIjFormat(module.getLanguageLevel().orElse(null)));
moduleContents.add("moduleType", module.getModuleType().orElse(IjModuleType.DEFAULT));
moduleContents.add("metaInfDirectory", module.getMetaInfDirectory().map((dir) -> module.getModuleBasePath().relativize(dir)).orElse(null));
writeToFile(moduleContents, path);
return path;
}
Aggregations