Search in sources :

Example 6 with ST

use of edu.princeton.cs.algs4.ST in project buck by facebook.

the class IjProjectWriter method getST.

private static ST getST(StringTemplateFile file) throws IOException {
    URL templateUrl = Resources.getResource(IjProjectWriter.class, file.getFileName());
    String template = Resources.toString(templateUrl, StandardCharsets.UTF_8);
    return new ST(template, DELIMITER, DELIMITER);
}
Also used : ST(org.stringtemplate.v4.ST) URL(java.net.URL)

Example 7 with ST

use of edu.princeton.cs.algs4.ST in project buck by facebook.

the class IjProjectWriter method writeProjectSettings.

private void writeProjectSettings(IJProjectCleaner cleaner, IjProjectConfig projectConfig) throws IOException {
    Optional<String> sdkName = projectConfig.getProjectJdkName();
    Optional<String> sdkType = projectConfig.getProjectJdkType();
    if (!sdkName.isPresent() || !sdkType.isPresent()) {
        return;
    }
    projectFilesystem.mkdirs(IDEA_CONFIG_DIR_PREFIX);
    Path path = IDEA_CONFIG_DIR_PREFIX.resolve("misc.xml");
    ST contents = getST(StringTemplateFile.MISC_TEMPLATE);
    String languageLevelInIjFormat = getLanguageLevelFromConfig();
    contents.add("languageLevel", languageLevelInIjFormat);
    contents.add("jdk15", getJdk15FromLanguageLevel(languageLevelInIjFormat));
    contents.add("jdkName", sdkName.get());
    contents.add("jdkType", sdkType.get());
    writeToFile(contents, path);
    cleaner.doNotDelete(path);
}
Also used : Path(java.nio.file.Path) ST(org.stringtemplate.v4.ST)

Example 8 with ST

use of edu.princeton.cs.algs4.ST in project buck by facebook.

the class IjProjectWriter method writeModulesIndex.

private Path writeModulesIndex() throws IOException {
    projectFilesystem.mkdirs(IDEA_CONFIG_DIR_PREFIX);
    Path path = IDEA_CONFIG_DIR_PREFIX.resolve("modules.xml");
    ST moduleIndexContents = getST(StringTemplateFile.MODULE_INDEX_TEMPLATE);
    moduleIndexContents.add("modules", projectDataPreparer.getModuleIndexEntries());
    writeToFile(moduleIndexContents, path);
    return path;
}
Also used : Path(java.nio.file.Path) ST(org.stringtemplate.v4.ST)

Example 9 with ST

use of edu.princeton.cs.algs4.ST in project che by eclipse.

the class DynaProviderGenerator method generate.

public String generate() throws IOException {
    dynaClasses = new ArrayList<>();
    findDynaObjects();
    ST st = getTemplate();
    st.add("packageName", packageName);
    st.add("className", className);
    st.add("classes", dynaClasses);
    return st.render();
}
Also used : ST(org.stringtemplate.v4.ST)

Example 10 with ST

use of edu.princeton.cs.algs4.ST in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class StringTemplate method writeRow.

@Override
public void writeRow(D domainObject, Map<String, ContentInfo> contentInfo, PrintWriter writer) throws IOException {
    ST template = prepareTemplate(templatePrototype, domainObject, contentInfo);
    template.write(new NoIndentWriter(writer));
}
Also used : ST(org.stringtemplate.v4.ST) NoIndentWriter(org.stringtemplate.v4.NoIndentWriter)

Aggregations

ST (org.stringtemplate.v4.ST)197 GrammarAST (org.antlr.v4.tool.ast.GrammarAST)37 STGroup (org.stringtemplate.v4.STGroup)24 File (java.io.File)19 ArrayList (java.util.ArrayList)16 IOException (java.io.IOException)12 STGroupFile (org.stringtemplate.v4.STGroupFile)12 Path (java.nio.file.Path)10 Test (org.junit.Test)10 ATNFactory (org.antlr.v4.automata.ATNFactory)9 LexerATNFactory (org.antlr.v4.automata.LexerATNFactory)9 ParserATNFactory (org.antlr.v4.automata.ParserATNFactory)9 CodeGenerator (org.antlr.v4.codegen.CodeGenerator)9 SemanticPipeline (org.antlr.v4.semantics.SemanticPipeline)9 Grammar (org.antlr.v4.tool.Grammar)9 LexerGrammar (org.antlr.v4.tool.LexerGrammar)9 STGroupString (org.stringtemplate.v4.STGroupString)9 LinkedHashMap (java.util.LinkedHashMap)7 URL (java.net.URL)6 Map (java.util.Map)6