Search in sources :

Example 1 with TsTemplateLiteral

use of cz.habarta.typescript.generator.emitter.TsTemplateLiteral in project typescript-generator by vojtechhabarta.

the class ModelCompiler method processPathTemplate.

private static TsTemplateLiteral processPathTemplate(PathTemplate pathTemplate) {
    final List<TsExpression> spans = new ArrayList<>();
    for (PathTemplate.Part part : pathTemplate.getParts()) {
        if (part instanceof PathTemplate.Literal) {
            final PathTemplate.Literal literal = (PathTemplate.Literal) part;
            spans.add(new TsStringLiteral(literal.getLiteral()));
        }
        if (part instanceof PathTemplate.Parameter) {
            final PathTemplate.Parameter parameter = (PathTemplate.Parameter) part;
            spans.add(new TsIdentifierReference(parameter.getValidName()));
        }
    }
    return new TsTaggedTemplateLiteral(new TsIdentifierReference("uriEncoding"), spans);
}
Also used : TsExpression(cz.habarta.typescript.generator.emitter.TsExpression) TsStringLiteral(cz.habarta.typescript.generator.emitter.TsStringLiteral) TsTaggedTemplateLiteral(cz.habarta.typescript.generator.emitter.TsTaggedTemplateLiteral) TsTaggedTemplateLiteral(cz.habarta.typescript.generator.emitter.TsTaggedTemplateLiteral) TsTemplateLiteral(cz.habarta.typescript.generator.emitter.TsTemplateLiteral) TsStringLiteral(cz.habarta.typescript.generator.emitter.TsStringLiteral) TsObjectLiteral(cz.habarta.typescript.generator.emitter.TsObjectLiteral) ArrayList(java.util.ArrayList) TsParameter(cz.habarta.typescript.generator.TsParameter) TsIdentifierReference(cz.habarta.typescript.generator.emitter.TsIdentifierReference) PathTemplate(cz.habarta.typescript.generator.parser.PathTemplate)

Aggregations

TsParameter (cz.habarta.typescript.generator.TsParameter)1 TsExpression (cz.habarta.typescript.generator.emitter.TsExpression)1 TsIdentifierReference (cz.habarta.typescript.generator.emitter.TsIdentifierReference)1 TsObjectLiteral (cz.habarta.typescript.generator.emitter.TsObjectLiteral)1 TsStringLiteral (cz.habarta.typescript.generator.emitter.TsStringLiteral)1 TsTaggedTemplateLiteral (cz.habarta.typescript.generator.emitter.TsTaggedTemplateLiteral)1 TsTemplateLiteral (cz.habarta.typescript.generator.emitter.TsTemplateLiteral)1 PathTemplate (cz.habarta.typescript.generator.parser.PathTemplate)1 ArrayList (java.util.ArrayList)1