ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
10 lines (9 loc) • 648 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function getNewReplacementSourceFile(opts) {
var insertPos = opts.insertPos, newText = opts.newText, sourceFile = opts.sourceFile, _a = opts.replacingLength, replacingLength = _a === void 0 ? 0 : _a;
var currentText = sourceFile.getFullText();
var newFileText = currentText.substring(0, insertPos) + newText + currentText.substring(insertPos + replacingLength);
return sourceFile.global.compilerFactory.createTempSourceFileFromText(newFileText, { filePath: sourceFile.getFilePath() });
}
exports.getNewReplacementSourceFile = getNewReplacementSourceFile;