UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

42 lines (41 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var utils_1 = require("../../../utils"); var TextChange_1 = require("./TextChange"); var FileTextChanges = /** @class */ (function () { /** @private */ function FileTextChanges(context, compilerObject) { this._compilerObject = compilerObject; this._sourceFile = context.compilerFactory.getSourceFileFromCacheFromFilePath(compilerObject.fileName); } /** * Gets the file path. */ FileTextChanges.prototype.getFilePath = function () { return this._compilerObject.fileName; }; /** * Gets the source file if it was in the cache at the time of this class' creation. */ FileTextChanges.prototype.getSourceFile = function () { return this._sourceFile; }; /** * Gets the text changes */ FileTextChanges.prototype.getTextChanges = function () { return this._compilerObject.textChanges.map(function (c) { return new TextChange_1.TextChange(c); }); }; /** * Gets if this change is for creating a new file. */ FileTextChanges.prototype.isNewFile = function () { return !!this._compilerObject.isNewFile; }; tslib_1.__decorate([ utils_1.Memoize ], FileTextChanges.prototype, "getTextChanges", null); return FileTextChanges; }()); exports.FileTextChanges = FileTextChanges;