UNPKG

ts-budgie

Version:

Converts TypeScript code to Budgie.

47 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var program_1 = require("./compiler/program"); /** * Transforms TypeScript to Budgie. */ var Transformer = /** @class */ (function () { /** * Initializes a new instance of the Transformer class. * * @param dependencies Dependencies to be used for initialization. */ function Transformer(dependencies) { this.dependencies = dependencies; this.typeChecker = program_1.createProgramForFiles(dependencies.sourceFiles).getTypeChecker(); } /** * Transforms a source file to Budgie. * * @param sourceText Source file to transform. * @returns Raw and formatted results from transforming the source file. */ Transformer.prototype.transformSourceFile = function (sourceFile) { var transforms = this.getSourceFileTransforms(sourceFile); return { printed: this.dependencies.printer.printFile(sourceFile.text, transforms), transforms: transforms, }; }; /** * Creates transformations for a source file. * * @param sourceFile Source file to transform. * @param typeChecker Type checker for the source file. * @returns Transformations for the file, or a complaint for unsupported syntax. */ Transformer.prototype.getSourceFileTransforms = function (sourceFile) { return this.dependencies.service.transform({ contextOptions: this.dependencies.contextOptions, sourceFile: sourceFile, typeChecker: this.typeChecker, }); }; return Transformer; }()); exports.Transformer = Transformer; //# sourceMappingURL=transforms.js.map