Exemple #1
0
 public TemplateParser(string template)
 {
     this.template = template;
     this.parser   = new TypeScriptParser2(template);
     this.parser.allowDollarIds = true;
     this.reader = this.parser.reader;
 }
        public void addProjectFile(string fn, string content)
        {
            var file = TypeScriptParser2.parseFile(content, new SourcePath(this.projectPkg, fn.replace(new RegExp("\\.ts$"), "")));

            this.setupFile(file);
            this.projectPkg.addFile(file);
        }
Exemple #3
0
        public void addExprTemplate(string exprStr, CodeTemplate tmpl)
        {
            var expr = new TypeScriptParser2(exprStr, null).parseExpression();

            if (expr is UnresolvedCallExpression unrCallExpr && unrCallExpr.func is PropertyAccessExpression propAccExpr && propAccExpr.object_ is Identifier ident)
            {
                var callTmpl = new CallTemplate(ident.text, propAccExpr.propertyName, unrCallExpr.args.map(x => (((Identifier)x)).text), tmpl);
                this.addMethod($"{callTmpl.className}.{callTmpl.methodName}@{callTmpl.args.length()}", callTmpl);
            }
        public void addInterfacePackage(string libName, string definitionFileContent)
        {
            var libPkg = new Package(libName, true);
            var file   = TypeScriptParser2.parseFile(definitionFileContent, new SourcePath(libPkg, Package.INDEX));

            this.setupFile(file);
            libPkg.addFile(file, true);
            this.workspace.addPackage(libPkg);
        }
 public void setupNativeResolver(string content)
 {
     this.nativeFile    = TypeScriptParser2.parseFile(content);
     this.nativeExports = Package.collectExportsFromFile(this.nativeFile, true);
     foreach (var trans in this.getTransformers(true))
     {
         trans.visitFiles(new SourceFile[] { this.nativeFile });
     }
 }